Hi There
I have some serious problems with spring & JPA. Specifically, the entity manager proxied only opens a new hiberate entity manager session if I take the bean out of the application context, for example this works:
But,wirring another class using DI to gain access to the underlying UserManagerCode:UserManager um = (UserManager) ac.getBean("userManager"); User u = um.getUserByEmail("test@abc.com");
does not work, at all!. For example:
If I replace the injected bean with a call to ac.getBean("userManager"), the above example would work as expected.Code:private UserManager um; // injected through setter public void keepNewUsers(List<String> emails) { for (Iterator<String> i = emails.iterator(); i.hasNext(); ) { if ( null != um.getUserByEmail(i.next() ) i.remove(); } }
It seems that the injected bean does not honour the transaction attributes as annotated on the UserManager. As to why? I don't know.
Currently I'm using jdk 1.6.0-b105, hibernate 3.2.1, and hibernate enitity managager 3.2.1
Littering my code with references to underlying application context is not only a serious burden (which I'm not willing to undertake), but also turns spring into a very invasive framework. Not even speaking of how this is so anti-dependency injection.
Is there anyone else who encountered the same kind of problem? Or am I doing something wrong here? Can it be that 1.6 does not play well with CGLIB?



Reply With Quote