-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: HibernateException: collection not associated with session
PostPosted: Fri May 21, 2010 2:54 am 
Beginner
Beginner

Joined: Sat Sep 12, 2009 10:20 am
Posts: 44
I'm seeing a really strange error.

I basically do this:

pojo = getSession().load(getPersistentClass(), id);
Hibernate.initialize(pojo);
Hibernate.initialize(pojo.getChild());
Hibernate.initalize(pojo.getChild().getCollection());
.... etc .. to initialize the object graph so that I can evict a pojo and use it throughout ajax requests..

This error happens when a page initalized and then the initialize is run again after some ajax requests have called.
After investigating, it appeared that the pojo was serialized and thecollections were detached..
But if I thought that the getSession().load() should give me an attached pojo and with the entire graph attached...

Code:
Caused by: org.hibernate.HibernateException: collection is not associated with any session
    at org.hibernate.collection.AbstractPersistentCollection.forceInitialization(AbstractPersistentCollection.java:471)
    at org.hibernate.Hibernate.initialize(Hibernate.java:332)
    at com.conducive.data.pojo.Link.hibernateInitialize(Link.java:646)
    at com.conducive.data.pojo.LinkPartner.hibernateInitalize(LinkPartner.java:178)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:197)
    at com.conducive.data.pojo.LinkPartner_$$_javassist_30.hibernateInitalize(LinkPartner_$$_javassist_30.java)


Top
 Profile  
 
 Post subject: Re: HibernateException: collection not associated with session
PostPosted: Sun May 23, 2010 2:40 am 
Beginner
Beginner

Joined: Sat Sep 12, 2009 10:20 am
Posts: 44
We are still trying to get this to work..

Do I need to provide more detail? If so, what would be helpful?


Top
 Profile  
 
 Post subject: Re: HibernateException: collection not associated with session
PostPosted: Wed May 26, 2010 3:15 am 
Beginner
Beginner

Joined: Sat Sep 12, 2009 10:20 am
Posts: 44
We ended up having to make the collections fetch eager.

I think this might be a bug in @ElementCollection


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.