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: LazyInitializationException Arrays.sort (pojos)
PostPosted: Fri Sep 29, 2006 3:35 pm 
Newbie

Joined: Fri Sep 29, 2006 3:27 pm
Posts: 2
Has anyone tried to do the following:

- load several POJOs and save them all into an array, call it pojos.
- call java.util.Arrays.sort (pojos)
- Get the following error. I made user that the the session.close () nor disconnect was never called.

org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:56)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:98)
at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:158)
at org.nesg.plims.pojo.Organism$$EnhancerByCGLIB$$b627858.compareTo(<generated>)
at java.util.Arrays.mergeSort(Arrays.java:1156)
at java.util.Arrays.mergeSort(Arrays.java:1167)
at java.util.Arrays.sort(Arrays.java:1080)
...

Can anyone offer some help on this one?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 01, 2006 12:50 am 
Regular
Regular

Joined: Tue Sep 26, 2006 11:37 am
Posts: 115
Location: Sacramento, CA
Can you sort the POJOs when they are not proxied by Hibernate? Is compareTo() properly defined? The stack trace does not indicate an error accesing a property of the bean so maybe the error message is misleading?

You can try putting a breakpoint/log statement in your POJO's compareTo() and see if the code is called.

Hope this helps :)

Marius


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 02, 2006 10:50 am 
Newbie

Joined: Fri Sep 29, 2006 3:27 pm
Posts: 2
That helped.

My own compareTo method was never called, actually. From the stack trace, it looked a generated compareTo method was called instead.

Ultimately, I tried adding lazy="false" to my class definition:

<class name="org.nesg.plims.pojo.Organism" table="NESG_ORGANISM" lazy="false">

After that, the error went away.


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.