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

Documentation of PersistService does not match its implementation #947

Open
skuzzle opened this issue Aug 21, 2015 · 0 comments
Open

Documentation of PersistService does not match its implementation #947

skuzzle opened this issue Aug 21, 2015 · 0 comments

Comments

@skuzzle
Copy link

skuzzle commented Aug 21, 2015

The JavaDoc on its start() and stop() method states that nothing should happen if service is already started or stopped respectively. However, trying to call those methods twice results in an IllegalStateException being thrown by the implementation due to these checks:

public synchronized void start() {
    Preconditions.checkState(null == emFactory, "Persistence service was already initialized.");
    ...
}
public synchronized void stop() {
    Preconditions.checkState(emFactory.isOpen(), "Persistence service was already shut down.");
    ....
jjantunen added a commit to jjantunen/guice that referenced this issue Jan 27, 2016
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
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 a pull request may close this issue.

1 participant