-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Separated UnitOfWork and EntityManager #985
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ma/guice into unitofwork-annotation
This modification continues work of Andreas Viedma (andresviedma:unitofwork-annotation). Current solution of the EntityManager doesn't robustly support use of Transaction scoped EntityManager.If EntityManager is injected or emProvider.get() is called outside of the Transactional annotation, then this will lead to never closed EntityManager. (Current solution would need boilerplate UnitOfWork.end() calls). This behaviour is also different than in Guice 2.0 with warp-persist, where Transaction scoped EntityManager works. With this commit UnitOfWork and EntityManager are separated. This means that getting of EntityManager doesn't start UnitOfWork. If EntityManager scope needs to be different than transaction, UnitOfWork has to be explicitly started.UnitOfWork can be started with annotation or explicitly calling begin(). Annotation supports nested UnitOfWorks. If begin is called directly from UnitOfWork then it requires direct call to end() to end UnitOfWork.End call will always end UnitOfWork. Resolves issues: google#739, google#947
We found a Contributor License Agreement for you (the sender of this pull request) and all commit authors, but as best as we can tell these commits were authored by someone else. If that's the case, please add them to this pull request and have them confirm that they're okay with these commits being contributed to Google. If we're mistaken and you did author these commits, just reply here to confirm. |
If there is existing entitymanager when the unitofwork is started then existing entitymanager is cleared.
zubaidullo
approved these changes
Oct 4, 2017
copybara-service bot
pushed a commit
that referenced
this pull request
Apr 21, 2023
…because it leads to leaks. Fixes #739, fixes #997, fixes #730, fixes #985, fixes #959, fixes #731. This also adds an optional Options to the JpaPersistModule constructor, if users wish to use the legacy behavior. This is a breaking change, but to a better default value. Users who want to keep the dangerous form can opt back in with the options. PiperOrigin-RevId: 525852009
copybara-service bot
pushed a commit
that referenced
this pull request
Apr 21, 2023
…because it leads to leaks. Fixes #739, fixes #997, fixes #730, fixes #985, fixes #959, fixes #731. This also adds an optional Options to the JpaPersistModule constructor, if users wish to use the legacy behavior. This is a breaking change, but to a better default value. Users who want to keep the dangerous form can opt back in with the options. PiperOrigin-RevId: 525852009
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This modification uses work of Andreas Viedma
(andresviedma:unitofwork-annotation).
Current solution of the EntityManager doesn't robustly support use of
Transaction scoped EntityManager.If EntityManager is injected or
emProvider.get() is called outside of the Transactional annotation,
then this will lead to never closed EntityManager. (Current solution
would need boilerplate UnitOfWork.end() calls). This behaviour is also
different than in Guice 2.0 with warp-persist, where Transaction scoped
EntityManager works.
With this modification UnitOfWork and EntityManager are separated.
This means that getting of EntityManager doesn't start UnitOfWork.
If EntityManager scope needs to be different than transaction,
UnitOfWork has to be explicitly started.UnitOfWork can be started
with annotation or explicitly calling begin(). Annotation supports
nested UnitOfWorks. If begin is called directly from UnitOfWork then
it requires direct call to end() to end UnitOfWork.End call will always
end UnitOfWork.
Resolves issues: #739, #947