New issue 597 by michal.g...@gmail.com: Persist Extension:
UnitOfWork.begin() throws IllegalStateException when called multiple times
http://code.google.com/p/google-guice/issues/detail?id=597
Version: guice-persist-3.0-rc2
The implementation of UnitOfWork.begin() throws exception using
precondition:
Preconditions.checkState(null == entityManager.get(),
"Work already begun on this thread. Looks like you have called
UnitOfWork.begin() twice"
+ " without a balancing call to end() in between.");
The javadoc and documentation claims that unit of works can be nested and
the begin() method can be called multiple times with no harm. Moreover
every call to Provider<EntityManager>.get() calls that begin() method if
the work of unit is not in progress.
Why the precondition was added?
We should probably correct the javadoc.
Yes, that would be fine. The limitation that we can not nest unit of works
will have impact on users migrating from warp-persist. Would it be possible
to add "boolean isWorking()" method to the UnitOfWork interface?
Could you please describe what was the reasoning behind this?
Issue 604 has been merged into this issue.
Comment #4 on issue 597 by sberlin: Persist Extension: UnitOfWork.begin()
throws IllegalStateException when called multiple times
http://code.google.com/p/google-guice/issues/detail?id=597
(No comment was entered for this change.)
I have the same issue by using Guice and GWT requestfactory which assume to
use static entity manager on entity:
@MappedSuperclass
public class BaseEntity implements Serializable {
private static final long serialVersionUID = 1L;
@Inject
protected static Provider<EntityManager> emProvider;
....
public static final EntityManager entityManager() {
return emProvider.get();
}
/*
* (non-Javadoc)
*
* @see com.google.inject.AbstractModule#configure()
*/
@Override
protected void configure() {
install(new JpaPersistModule("xxxx"));
requestStaticInjection(BaseEntity.class);
}
Which is is the best practice using Guice-Persist extension and GWT
requestfactory?
Thank You in advance.
I had to move back quickly to warp-persist because of this precondition
(even if I do not use directly UnitOfWork but only the PersistFilter).
Nobody to answer the questions of the previous comments?