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.  [ 4 posts ] 
Author Message
 Post subject: Collection not loading
PostPosted: Thu Aug 03, 2006 3:08 pm 
Newbie

Joined: Fri Jul 07, 2006 9:36 am
Posts: 15
Hi,
I am having an issue with a "Collection" not loading.
I am using lazy="false" in my hibernate mapping file.

One thing I have noticed is that if I use the ".get" method using the key object, the collecion does not load. However, if I find the row of data using a simple HQL query then the collection does load successfully.

I have tried using "Hibernate.initialize(...).
Not luck.

Any suggestions/ideas would be greatly appreciated !



<< HIBERNATE MAPPING >>

<hibernate-mapping package="us.nc.state.doc.ws.hibernate.bean.offender">
<class name="Ofnt7ih1" table="OFNV7IH1" lazy="false">
<composite-id name="id" class="Ofnt7ih1Id">
<key-property name="facilityId" type="string" column="CFFACLID" length="5" />
<key-property name="offenderNumber" type="string" column="CMDORNUM" length="7" />
<key-property name="intakeDate" type="date" column="INTKDATE" length="10" />
</composite-id>
<property name="intakeStatus" type="string" column="INTKSTAT" length="3" not-null="true" />
<property name="statusDate" type="date" column="STATUSDATE" length="10" not-null="true" />
<property name="dateOfEntry" type="date" column="DTOFENTRY" length="10" not-null="true" />
<property name="timestampOfEntry" type="timestamp" column="TSOFUPDT" length="26" not-null="true" />
<property name="staffOfUpdate" type="string" column="STFOFUPDT" length="5" not-null="true" />
<set name="detailItems" cascade="all" inverse="false" lazy="false">
<key>
<column name="CFFACLID"/>
<column name="CMDORNUM"/>
<column name="INTKDATE"/>
</key>
<one-to-many class="Ofnt7id1"/>
</set>
</class>

<class name="Ofnt7id1" table="OFNV7ID1">
<composite-id name="id" class="Ofnt7id1Id">
<key-property name="facilityId" type="string" column="CFFACLID" length="5" />
<key-property name="offenderNumber" type="string" column="CMDORNUM" length="7" />
<key-property name="intakeDate" type="date" column="INTKDATE" length="10" />
<key-property name="intakeTask" type="string" column="INTKTASK" length="3" />
<key-property name="timestampOfCreate" type="timestamp" column="TSOFCREAT" length="26" />
</composite-id>
<property name="staffIdOfInterview" type="string" column="INTKSTFID" length="5" not-null="true" />
<property name="taskDate" type="date" column="INTKTASKDT" length="10" not-null="true" />
<property name="interviewResponsibility" type="string" column="INTKRESP" length="2" not-null="true" />
<property name="interviewTaskOrder" type="long" column="INTKORDR" precision="4" scale="0" not-null="true" />
<property name="interviewTaskStatus" type="string" column="INTKSTFLG" length="1" not-null="true" />
<property name="timestampOfUpdate" type="timestamp" column="TSOFUPDT" length="26" not-null="true" />
<property name="staffOfUpdate" type="string" column="STFOFUPDT" length="5" not-null="true" />
</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 03, 2006 3:40 pm 
Newbie

Joined: Fri Jul 07, 2006 9:36 am
Posts: 15
I am using Hibernate 3.1.3


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 03, 2006 5:07 pm 
Beginner
Beginner

Joined: Wed Jun 21, 2006 10:08 am
Posts: 26
I found placing default-lazy="false" in the <hibernate-mapping> file, then my collections would be loaded. When I placed it in the <class> tag like you did, it did not load my collections. I am not exactly sure why.

_________________
- Jonathan


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 04, 2006 8:36 am 
Newbie

Joined: Fri Jul 07, 2006 9:36 am
Posts: 15
Hi huangjd,

I tried your suggestion, but no luck. The collection is not initialized. I have created a a method in my DAO that finds the database row using the primary key

i.e. query.uniqueResult();

This works perfectly. I am curious why the get/load methods do not work.


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