Skip to content

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

gavinking
Copy link
Member

@gavinking gavinking commented Jun 5, 2025

[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

@hibernate-github-bot
Copy link

hibernate-github-bot bot commented Jun 5, 2025

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 HHH-\d+
    ↳ Offending commits: [9d20671]

› This message was automatically generated.

gavinking added 2 commits June 5, 2025 23:18
upsert() should throw StaleObjectStateException if the version
verification fails
gavinking added 2 commits June 5, 2025 23:35
- also fix the problem for upsert emulation with UPDATE/INSERT
Comment on lines 195 to 217
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 );
Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant