Announcement Announcement Module
Collapse
No announcement yet.
problems loading aop-proxied bean with hibernate Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • problems loading aop-proxied bean with hibernate

    i'am trying to load a user bean from db via hibernate. the user bean is a session-scoped bean (aop-proxy). i've added the ScopedBeanInterceptor, so now i don't get an unknown enitity exception anymore.

    but when i'm trying to load it with session.load() the bean afterwards hasn't changed.
    spring-config:
    Code:
    <bean id="user" class="testapp.models.User" scope="session">
    		<aop:scoped-proxy/>
    	</bean>
    java-dao-code:
    Code:
    public void findById(User user, Long id) {
    		if (user == null)
    			throw new IllegalArgumentException("user is NULL");
    		if (id == null)
    			throw new IllegalArgumentException("id is NULL");
    
    		Session session = sessionFactory.openSession();
    
    		user.setName("unset");
    		session.load(user, u.getId());
    		LOG.debug("user '" + user.getName() + "' found!"); // user 'unset' found!
    		
    		session.close();
    	}
    when i call the dao-function with a new instance of User and id 1 it works (log-message is user 'Administrator' found!), but when i call it with an aop-proxied User and id 1 i get the log-message user 'unset' found!

    can you help me?
    Last edited by giga; May 28th, 2011, 01:32 PM.

  • #2
    That simply is never going to work... You would need to copy the properties of the hibernate loaded entity to the session scoped bean. A session scoped bean is something else as a hibernate entity.

    Comment

    Working...
    X