-
Notifications
You must be signed in to change notification settings - Fork 38.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JdbcTemplate should store generated keys only if database driver supports it #31463
Conversation
It might be worth reading similar questions asked on jooq's github some years ago, as apparently There's also jOOQ/jOOQ#8993 (comment) where apparently returning null from |
So your code is calling a If we consider key retrieval as sort-of-optional even for our However, I'm still concerned by the mismatch with the javadoc for our |
@jhoeller you are correct - we can use update without keys |
Thanks for the follow-up. I've created #31486 to review the Javadoc. |
Hi all, |
Not every database supports
PreparedStatement#getGeneratedKeys()
, for example, SQLLitle does not, and calling this method throws an exception, it has been discussed here: xerial/sqlite-jdbc#996JdbcTemplate
callsPreparedStatement#getGeneratedKeys()
whether it's supported or not, and in the case of SQLLitle, it causes an exception.This PR changes the behavior of
JdbcTemplate
that it will callPreparedStatement#getGeneratedKeys()
only if the underlying driver supports it by querying:DatabaseMetaData#supportsGetGeneratedKeys()
.