Skip to content
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

ENH: Add Transaction.rollbackAndContinue() #2819

Merged
merged 2 commits into from
Sep 1, 2022

Conversation

rbygrave
Copy link
Member

@rbygrave rbygrave commented Sep 1, 2022

Typically useful for handling DuplicateKeyException where we expect
DuplicateKeyException to be thrown and catch it with the intention of
continuing processing using the same transaction.

Note that some databases like Oracle do not require this explicit
rollback() and would work without the rollbackAndContinue(). Postgres
in particular requires the rollback() call on the underlying connection
such that we can continue using that transaction/java.sql.Connection.

Note that in the existing test we can see that rollbackAndContinue()
is pretty close to being syntactic sugar. I think adding rollbackAndContinue()
is justified and complements the existing commitAndContinue().

Typically useful for handling DuplicateKeyException where we expect
DuplicateKeyException to be thrown and catch it with the intention of
continuing processing using the same transaction.

Note that some databases like Oracle do not require this explicit
rollback() and would work without the rollbackAndContinue(). Postgres
in particular requires the rollback() call on the underlying connection
such that we can continue using that transaction/java.sql.Connection.

Note that in the existing test we can see that rollbackAndContinue()
is pretty close to being syntactic sugar. I think adding rollbackAndContinue()
is justified and complements the existing commitAndContinue().
@rbygrave rbygrave self-assigned this Sep 1, 2022
@rbygrave rbygrave added this to the 13.9.1 milestone Sep 1, 2022
@rbygrave rbygrave merged commit f86a0ac into master Sep 1, 2022
@vilmosnagy
Copy link
Contributor

vilmosnagy commented Sep 3, 2022

@rbygrave the isActive method was made final by this PR, and broke the spring-jdbc transactions.See: ebean-orm/ebean-spring-txn#28

Do you have any better idea than to make the isActive method non-final again? Would you merge such PR?

@rbygrave rbygrave deleted the feature/enh-addRollbackAndContinue branch February 19, 2023 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants