-->
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: some problem about "lazy"
PostPosted: Wed Nov 17, 2004 10:15 pm 
Newbie

Joined: Wed Nov 17, 2004 10:04 pm
Posts: 1
Hibernate version:2.16

Mapping documents:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="Productinfomain" table="ProductInfoMain" lazy="true">
<id name="id" column="sSysID" type="string">
<generator class="uuid.hex"/>
</id>
<property name="sproductid" column="sProductID" type="string" length="20"/>
<property name="sproductdisplayid" column="sProductDisplayID" type="string" length="20"/>
<property name="sproductname" column="sProductName" type="string" length="50"/>
<property name="sproductoccasion" column="sProductOccasion" type="string" length="50"/>
<property name="smodel" column="sModel" type="string" length="50"/>

<many-to-one name="producttypeObj" class="Sysbasicinfodetail" column="sProducttype" cascade="none" outer-join="auto" insert="false" update="false"></many-to-one>

</class>
</hibernate-mapping>

------------------------------------------------------

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="Sysbasicinfodetail" table="sysBasicInfoDetail" lazy="true">
<id name="id" column="sSysID" type="string">
<generator class="uuid.hex"/>
</id>
<property name="sitemname" column="sItemName" type="string" length="20"/>
<property name="sitemvalue" column="sItemValue" type="string" length="20"/>
</class>
</hibernate-mapping>



Productinfomain productinfomain =(Productinfomain) this.session.load(Productinfomain.class, sysID);
Sysbasicinfodetail producttype = productinfomain.getProducttypeObj();


I intend to use "lazy" to get associated object like this:


Productinfomain productinfomain =(Productinfomain) this.session.load(Productinfomain.class, sysID);
Sysbasicinfodetail producttype = productinfomain.getProducttypeObj();

i found the producttype is null,the class Sysbasicinfodetail mapping not work, why ?
but when i drop the lazy="true" in class Productinfomain mapping ,above code work well.
I am perplexed on why the Productinfomain mapping drop lazy="true" it work well?

Any help please reply back. Thanks
Name and version of the database you are using:sql server 2000


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 17, 2004 10:57 pm 
Newbie

Joined: Wed Feb 25, 2004 11:41 pm
Posts: 19
Location: China
use Hibernate.initialize() before session close

furthermore,read chapter 12 in DOC

_________________
who can tell me why?


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.