-->
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.  [ 1 post ] 
Author Message
 Post subject: How to solve LazyInitializationException ?
PostPosted: Sat Nov 13, 2004 10:31 am 
Regular
Regular

Joined: Mon Aug 02, 2004 9:33 am
Posts: 69
Hibernate version:2.1.6

Mapping documents:
PostingIdentification.class

<set
name="classifiedItem"
table="ClassifiedItem"
lazy="false"
cascade="save-update"
sort="unsorted"
>

<key
column="FK_ITEMID"
>
</key>

<one-to-many
class="com.abc.model.businessobject.Posting.ClassifiedItem"
/>
=======================================

ClassifiedItem.class

<many-to-one
name="postingIdentification"
class="com.abc.model.businessobject.Posting.PostingIdentification"
cascade="none"
outer-join="auto"
column="FK_ITEMID"
unique="true"
/>
=======================================

Full stack trace of any exception that occurs:

[junit] Testcase: testGetImagesByPostId(com.abc.model.dao.PostingDAOTest): Caused an ERROR
[junit] Failed to lazily initialize a collection
[junit] net.sf.hibernate.LazyInitializationException: Failed to lazily initialize a collection
[junit] at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:201)
[junit] at net.sf.hibernate.collection.PersistentCollection.read(PersistentCollection.java:71)
[junit] at net.sf.hibernate.collection.Set.hashCode(Set.java:383)
[junit] at org.apache.commons.lang.builder.HashCodeBuilder.append(HashCodeBuilder.java:392)

Name and version of the database you are using:MySQL 4.1.7

Hi guys,

I got 2 persistent class, which is one-to-many(PostingIdentification.java) and many-to-one (ClassifiedItem.java). I tried to implement to hashCode() and toString() and equal() using Commonclipse. After that when I tried to do a query like follows:

* @hibernate.query name="PostingListByAmount"
* query="select pid from PostingIdentification pid join pid.classifiedItem classitem where classitem.amount <= ?"
*


then I got the stack trace. But after removing the hashCode(), toString and equal(), the problem gone. Please help, Thanks !

rgrds,
prettyhandling


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

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.