-->
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.  [ 2 posts ] 
Author Message
 Post subject: LazyInitialization and hashCode() method in POJO.
PostPosted: Thu Jun 12, 2008 12:31 am 
Newbie

Joined: Thu Jun 05, 2008 11:45 pm
Posts: 6
Hi,
I was facing lazyinitialization problem and used OpenSessionInViewFilter to avoid it. This worked in some places but failed in others. All the errors come in the hashCode() method that I have implemented in my POJO's. These come for the objects which are retreived as Lazy.
I have a basic question which may be very stupid, but please bear with me.
Can I change the hashCode() method to include only those objects that are not fetched lazily? What would be the side effects in such a case?Could any one please help me with this? Am stuck with this problem for a long time now.

Thanks

Error Trace That I am getting
------------
org.hibernate.LazyInitializationException: could not initialize proxy - no Session
at org.hibernate.proxy.AbstractLazyInitializer.initia lize(AbstractLazyInitializer.java:57)
at org.hibernate.proxy.AbstractLazyInitializer.getImp lementation(AbstractLazyInitializer.java:111)
at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitialize r.invoke(CGLIBLazyInitializer.java:150)
at com.cpt.his.model.ICPCategory$$EnhancerByCGLIB$$a8 a4fd72.hashCode(<generated>)
at org.apache.commons.lang.builder.HashCodeBuilder.ap pend(HashCodeBuilder.java:856)
at com.cpt.his.model.ICP.hashCode(ICP.java:175)
at java.util.HashMap.hash(HashMap.java:264)
at java.util.HashMap.put(HashMap.java:382)
at java.util.HashSet.add(HashSet.java:194)
at org.apache.commons.lang.builder.ToStringStyle.regi ster(ToStringStyle.java:151)
at org.apache.commons.lang.builder.ToStringStyle.appe ndClassName(ToStringStyle.java:1403)
at org.apache.commons.lang.builder.ToStringStyle.appe ndStart(ToStringStyle.java:328)
at org.apache.commons.lang.builder.ToStringBuilder.<i nit>(ToStringBuilder.java:255)
at org.apache.commons.lang.builder.ToStringBuilder.<i nit>(ToStringBuilder.java:212)
at com.cpt.his.model.ICP.toString(ICP.java:184)
at ognl.OgnlOps.stringValue(OgnlOps.java:285)
at ognl.OgnlOps.stringValue(OgnlOps.java:302)
at ognl.OgnlOps.convertValue(OgnlOps.java:367)


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 14, 2008 9:33 am 
Regular
Regular

Joined: Sun Apr 13, 2008 3:04 am
Posts: 71
Location: Bangalore
May be this URL http://www.hibernate.org/hib_docs/refer ... asses.html would give you more info on side effections

Regards,
Nagendra

_________________
Raja Nagendra Kumar,
C.T.O
http://www.tejasoft.com
TejaSoft - Specialists in Code Audit, Unit Testing and Merciless Re-factoring - Engineering Crisis Turnaround Experts


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.