I am using guice 4.1 along with the persist extension and hoping that @Transactional will work, but it isn't. I followed the wiki and read this post, but to no avail:
Managing transactions in JavaSE with Hibernate and Guice
Just to re-iterate ... I am doing:
- depending on guice-persist
- using google's @Transactional annotation
- using the annotation only on public or protected methods that are managed by guice
- starting the PersistService ...
We ran into something similar when upgrading our libraries in our current Sprint. All our failing unit tests were related to classes that we're being injected, but were not bound in the module.
(Which wasn't a problem using Guice 4.0).
We tend to only bind our classes if we bind to an interface or some special requirement. So if we had a simple class that had a zero argument constructor or was annotated with @Inject, we wouldn't bind it in the module.
If the class AA was injected, calling test() would output
After upgrading to Guice 4.1 the output is
Adding the following to the module changes the injection back to a proxy. Which is how the @Transactional works using AOP