-->
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.  [ 7 posts ] 
Author Message
 Post subject: Lazy loading not working and driving me nuts..
PostPosted: Mon Feb 07, 2005 8:04 pm 
Beginner
Beginner

Joined: Mon Dec 08, 2003 12:15 am
Posts: 47
I am trying to load a unitCoverages (see below) collection lazily from a Unit persistent class and although it seems like all the queries are running fine etc...etc.., my objects are not being loaded. This is driving me insane. If anyone can spot the issue please let me know. All relevant code is belos

Hibernate version:2.18

Mapping documents:
<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class
name="com.uaig.migration.history.as400.vo.Unit"
table="UQXXUNIT"
dynamic-update="false"
dynamic-insert="false"
>

<composite-id
name="unitPK"
class="com.uaig.migration.history.as400.vo.UnitPK"
>
<key-property
name="referenceNumber"
type="java.lang.Integer"
column="UUREFNO"
/>

<key-property
name="unitNumber"
type="java.lang.Integer"
column="UUNITNO"
/>
</composite-id>

<property
name="companyNumber"
type="java.lang.String"
column="UUCOMP#"
/>

<property
name="policyPrefix"
type="java.lang.String"
column="UUPRFXN"
/>

<property
name="policyNumber"
type="java.lang.Integer"
column="UUPLNBR"
/>

<property
name="unitType"
type="java.lang.String"
update="true"
insert="true"
column="UUNITTY"
length="2"
/>

<property
name="unitGroup"
type="java.lang.String"
update="true"
insert="true"
column="UUNITGR"
length="2"
/>

<property
name="vinId"
type="java.lang.String"
update="true"
insert="true"
column="UUVINID"
length="25"
/>

<property
name="unitYear"
type="java.lang.Integer"
update="true"
insert="true"
column="UUYEAR"
length="4"
/>

<property
name="unitMake"
type="java.lang.String"
update="true"
insert="true"
column="UUMAKE"
length="4"
/>

<property
name="unitModel"
type="java.lang.String"
update="true"
insert="true"
column="UUMODL"
length="10"
/>

<property
name="description"
type="java.lang.String"
update="true"
insert="true"
column="UUDESC"
length="30"
/>

<property
name="garageZipCode"
type="java.lang.String"
update="true"
insert="true"
column="UUZIPC"
length="9"
/>

<property
name="countyName"
type="java.lang.String"
update="true"
insert="true"
column="UUCNTY"
length="20"
/>

<property
name="cityName"
type="java.lang.String"
update="true"
insert="true"
column="UUCITY"
length="20"
/>

<property
name="countyCode"
type="java.lang.String"
update="true"
insert="true"
column="UUCNTCD"
length="5"
/>

<property
name="unitStatus"
type="java.lang.String"
update="true"
insert="true"
column="UUSTUS"
length="1"
/>

<property
name="unitActivity"
type="java.lang.String"
update="true"
insert="true"
column="UUACTY"
length="1"
/>

<property
name="mileToWork"
type="java.lang.Integer"
update="true"
insert="true"
column="UUMILE"
length="3"
/>

<property
name="deleteDate"
type="java.util.Date"
update="true"
insert="true"
column="UUDELDT"
length="7"
/>

<property
name="addDate"
type="java.util.Date"
update="true"
insert="true"
column="UUADDDT"
length="7"
/>

<property
name="ratedClass"
type="java.lang.String"
update="true"
insert="true"
column="UURCLS"
length="6"
/>

<property
name="odometerReading"
type="java.lang.Integer"
update="true"
insert="true"
column="UUODOM"
length="7"
/>

<property
name="ratedSymbol"
type="java.lang.String"
update="true"
insert="true"
column="UURSYMB"
length="2"
/>

<property
name="useCode"
type="java.lang.String"
update="true"
insert="true"
column="UUPUSEC"
length="2"
/>

<property
name="territory"
type="java.lang.String"
update="true"
insert="true"
column="UUTERR"
length="3"
/>

<property
name="passiveRest"
type="java.lang.String"
update="true"
insert="true"
column="UUPSRT"
length="2"
/>

<property
name="antiTheft"
type="java.lang.String"
update="true"
insert="true"
column="UUANTF"
length="2"
/>

<property
name="antiLock"
type="java.lang.String"
update="true"
insert="true"
column="UUANTLK"
length="2"
/>

<property
name="multiCar"
type="java.lang.String"
update="true"
insert="true"
column="UUMULTC"
length="1"
/>

<property
name="transferDiscount"
type="java.lang.String"
update="true"
insert="true"
column="UUTRNFD"
length="1"
/>

<property
name="ratedPDriver"
type="java.lang.Integer"
update="true"
insert="true"
column="UURTDRV"
length="3"
/>

<property
name="replacementCost"
type="java.lang.Integer"
update="true"
insert="true"
column="UURPLCT"
length="7"
/>

<property
name="customEquipment"
type="java.lang.String"
update="true"
insert="true"
column="UUCUSTE"
length="2"
/>

<property
name="highSymbolSurch"
type="java.lang.String"
update="true"
insert="true"
column="UUHGSYM"
length="2"
/>

<property
name="goodSafeDriver"
type="java.lang.String"
update="true"
insert="true"
column="UUSNRDR"
length="1"
/>

<property
name="unitChange"
type="java.lang.String"
update="true"
insert="true"
column="UUNITCH"
length="1"
/>

<property
name="vinChange"
type="java.lang.String"
update="true"
insert="true"
column="UUVINCH"
length="1"
/>

<set
name="unitCoverages"
lazy="false"
inverse="true"
cascade="all-delete-orphan"
>
<key>
<column name="UCREFNO" />
<column name="UCNITNO" />
</key>

<one-to-many
class="com.uaig.migration.history.as400.vo.Coverage"
/>
</set>
</class>
</hibernate-mapping>

<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
<class
name="com.uaig.migration.history.as400.vo.Coverage"
table="UQXXCOVG"
dynamic-update="false"
dynamic-insert="false"
>
<composite-id
name="coveragePK"
class="com.uaig.migration.history.as400.vo.CoveragePK"
>
<key-property
name="referenceNumber"
type="java.lang.Integer"
column="UCREFNO"
/>

<key-property
name="unitNumber"
type="java.lang.Integer"
column="UCNITNO"
/>

<key-property
name="coverageCode"
type="java.lang.String"
column="UCOVGCD"
/>

</composite-id>

<property
name="companyNumber"
type="java.lang.String"
column="UCCOMP#"
length="2"
/>

<property
name="policyPrefix"
type="java.lang.String"
column="UCPRFXN"
length="4"
/>

<property
name="policyNumber"
type="java.lang.Integer"
column="UCPLNBR"
length="9"
/>

<property
name="coverageDescription"
type="java.lang.String"
update="true"
insert="true"
column="UCOVGDS"
length="40"
/>

<property
name="coverageLimit"
type="java.lang.String"
update="true"
insert="true"
column="UCOVGLM"
length="13"
/>

<property
name="coverageDeductible"
type="java.lang.Integer"
update="true"
insert="true"
column="UCOVGDU"
length="9"
/>

<property
name="coverageDeductibleType"
type="java.lang.String"
update="true"
insert="true"
column="UCOVGDT"
length="1"
/>

<property
name="coverageStatus"
type="java.lang.String"
update="true"
insert="true"
column="UCOVGST"
length="1"
/>

<property
name="coverageAddDate"
type="java.util.Date"
update="true"
insert="true"
column="UCOVGAD"
length="7"
/>

<property
name="coverageDeleteDate"
type="java.util.Date"
update="true"
insert="true"
column="UCOVGDD"
length="7"
/>

<property
name="coverageInfPrm"
type="java.math.BigDecimal"
update="true"
insert="true"
column="UCOVGIP"
length="11"
/>

<property
name="coverageWrittenPremium"
type="java.math.BigDecimal"
update="true"
insert="true"
column="UCWRTPM"
length="11"
/>

<property
name="coverageValue"
type="java.lang.Long"
update="true"
insert="true"
column="UCOVGVL"
length="11"
/>

<property
name="coverageChange"
type="java.lang.String"
update="true"
insert="true"
column="UCOVGCH"
length="1"
/>

</class>

</hibernate-mapping>




Code between sessionFactory.openSession() and session.close():

UnitPK pk = new UnitPK();
pk.setReferenceNumber(new Integer(600100));
pk.setUnitNumber(new Integer(1));
Unit un = (Unit) as400Session.load(Unit.class,pk);

//Unit has a set called unitCoverages which is not being loaded although in the mapping doc it is set for non-lazy load

//commit session
/close session....


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 08, 2005 11:37 am 
Expert
Expert

Joined: Sat Jan 17, 2004 2:57 pm
Posts: 329
Location: In the basement in my underwear
So when you say that unit coverages isn't loaded do you mean you get a lazy init error when you try to access the set or that it comes back empty? If you get a lazy init then something is amiss, if you get nothing back then maybe your relationship (and or data) is flawed.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 08, 2005 11:43 am 
Beginner
Beginner

Joined: Mon Dec 08, 2003 12:15 am
Posts: 47
The set is empty so according to your train of thought, the relationship and/or data is flawed. The problem is that I am sure there is data in the relationship. So what other flaw in the data could there be that is causing this to fail??


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 08, 2005 4:38 pm 
Expert
Expert

Joined: Sat Jan 17, 2004 2:57 pm
Posts: 329
Location: In the basement in my underwear
I am assuming that Hibernate is populating your properties via mutatators? Debug that to see when it gets called what Hibernate is passing in.

Also, show your object code, silly as it sounds there might be something that is amiss in there.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 08, 2005 5:23 pm 
Beginner
Beginner

Joined: Mon Dec 08, 2003 12:15 am
Posts: 47
I found another thread that has exactly the same problem as I am encountering. If you are interested, you can find it here:

http://forum.hibernate.org/viewtopic.php?t=937838

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 08, 2005 6:16 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
So, I take it your problem is resolved then, using the same solution....


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 08, 2005 6:44 pm 
Expert
Expert

Joined: Sat Jan 17, 2004 2:57 pm
Posts: 329
Location: In the basement in my underwear
Have you posted your java classes and/or debugged to see what those sets are being set to? I've seen issues where a setter was defined as

setX(Set x)
{
this.someOtherCollectionNotX = x;
}


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