Open GoogleCodeExporter opened 9 years ago
I've created a git patch which addresses this issue, as well as issue 731.
Rundown of changes from the commit log:
- JpaPersistService now counts invocations of begin() and end(), and only closes
EntityManager when end() has been called an appropriate number of times
- Attempting to get an EntityManager outside of an active UnitOfWork now results
in an IllegalStateException
- Added a new @WorkUnit annotation. This is equivalent to the @Transactional
annotation for methods/classes which access the database but do not modify it
Patch also updates the appropriate unit tests.
Original comment by spootsy....@gmail.com
on 10 Oct 2012 at 11:44
Attachments:
@WorkUnit annotation, is this similar to Spring's @Transactional(readOnly =
true)
http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html
/transaction.html#transaction-declarative-annotations
http://static.springsource.org/spring/docs/3.1.x/javadoc-api/org/springframework
/transaction/annotation/Transactional.html#readOnly()
IMO, readOnly=true expresses the transaction's behavior clearly that the
changes will not be committed.
Original comment by prashant...@gmail.com
on 11 Oct 2012 at 1:54
@WorkUnit is just a shorthand means of using the UnitOfWork interface, by
wrapping the annotated method with calls to uow.begin/uow.end in a try/finally
block. No JPA transaction is explicitly started.
I think it's conceptually different from a read-only transaction. That would
certainly make more sense as an additional attribute on the existing
@Transactional annotation.
Original comment by spootsy....@gmail.com
on 11 Oct 2012 at 3:11
Will this fix be part of Guice 4.0?
Original comment by bimsc...@gmail.com
on 22 Aug 2013 at 9:38
[deleted comment]
I was hoping they'd include a patch of some kind but I don't see any changes in
trunk. It's a shame, because the current semantics of UnitOfWork are pretty
badly broken IMHO.
Also, please note there's a significant bug in this patch, as discussed here:
http://code.google.com/p/google-guice/issues/detail?id=731
It's a simple fix but I haven't got around to it yet. If anybody else has a
vested interest you're more than welcome to fix it and post the updated patch
here.
Original comment by spootsy....@gmail.com
on 23 Aug 2013 at 5:01
Original comment by sberlin
on 20 Dec 2013 at 2:17
Original issue reported on code.google.com by
spootsy....@gmail.com
on 27 Sep 2012 at 2:48Attachments: