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
|