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
|