-
Notifications
You must be signed in to change notification settings - Fork 3.6k
HHH-19522 upsert should not fail silently instead of throwing StaleObjectStateException #10289
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
base: main
Are you sure you want to change the base?
Conversation
Thanks for your pull request! This pull request does not follow the contribution rules. Could you have a look? ❌ All commit messages should start with a JIRA issue key matching pattern › This message was automatically generated. |
upsert() should throw StaleObjectStateException if the version verification fails
- also fix the problem for upsert emulation with UPDATE/INSERT
- also fix the problem for Oracle
final var statementDetails = statementGroup.resolvePreparedStatementDetails( tableMapping.getTableName() ); | ||
try { | ||
final PreparedStatement updateStatement = statementDetails.resolveStatement(); | ||
session.getJdbcServices().getSqlStatementLogger().logStatement( statementDetails.getSqlString() ); | ||
final JdbcServices jdbcServices = session.getJdbcServices(); | ||
jdbcServices.getSqlStatementLogger().logStatement( statementDetails.getSqlString() ); | ||
jdbcValueBindings.beforeStatement( statementDetails ); | ||
final int rowCount = | ||
session.getJdbcCoordinator().getResultSetReturn() | ||
.executeUpdate( updateStatement, statementDetails.getSqlString() ); | ||
MODEL_MUTATION_LOGGER.tracef( "`%s` rows upserted into `%s`", rowCount, tableMapping.getTableName() ); | ||
try { | ||
expectation.verifyOutcome( rowCount, updateStatement, -1, statementDetails.getSqlString() ); | ||
} | ||
catch (SQLException e) { | ||
throw jdbcServices.getSqlExceptionHelper().convert( | ||
e, | ||
"Unable to verify outcome for upsert", | ||
statementDetails.getSqlString() | ||
); | ||
} | ||
} | ||
finally { | ||
statementDetails.releaseStatement( session ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sebersole Why does this stuff not go through a MutationCoordinator
/MutationExecutor
?
I'm not clear on how these differ from MutationOperation
.
[Please describe here what your change is about]
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license
and can be relicensed under the terms of the LGPL v2.1 license in the future at the maintainers' discretion.
For more information on licensing, please check here.
https://hibernate.atlassian.net/browse/HHH-19522