Announcement Announcement Module
Collapse
No announcement yet.
Problems with JPA'ed proxied beans in spring 2.0 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problems with JPA'ed proxied beans in spring 2.0

    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:
    Code:
        UserManager um = (UserManager) ac.getBean("userManager");
        User u = um.getUserByEmail("[email protected]");
    But,wirring another class using DI to gain access to the underlying UserManager
    does not work, at all!. For example:
    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();
            }
        }
    If I replace the injected bean with a call to ac.getBean("userManager"), the above example would work as expected.

    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?
Working...
X