Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:3.1
Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping>
<class name="vo.as400.CFatteVO" table="sdgtwb_dat.fatte00f" lazy="false">
<composite-id name="pk" class="vo.pk.CFattePK" >
<key-property name="SOFAFT" column="SOFAFT" />
<key-property name="AAFAFT" column="AAFAFT" />
<key-property name="SFATFT" column="SFATFT" type="dao.hibernate.TrimmedString" />
<key-property name="NFATFT" column="NFATFT" />
</composite-id>
<property name="STREFT" column="STREFT" type="dao.hibernate.TrimmedString" />
<property name="NRAZFT" column="NRAZFT" />
<property name="DTUMFT" column="DTUMFT" />
<property name="ORUMFT" column="ORUMFT" />
<property name="BLREFT" column="BLREFT" type="dao.hibernate.TrimmedString" />
.....
<set name="righe" lazy="false" >
<key>
<column name="SOFAFR"/>
<column name="AAFAFR"/>
<column name="SFATFR"/>
<column name="NFATFR"/>
</key>
<one-to-many class="vo.as400.CFattriVO"/>
</set>
<many-to-one name="cliente" class="vo.as400.CClienteVO" lazy="false" update="false" insert="false" not-null="true" not-found="ignore" >
<column name="CDFAFT"/>
</many-to-one>
</class>
</hibernate-mapping>
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping>
<class name="vo.as400.CFattriVO" table="sdgtwb_dat.fatri00f" lazy="false" >
<composite-id name="pk" class="vo.pk.CFattriPK" >
<key-property name="SOFAFR" column="SOFAFR" />
<key-property name="AAFAFR" column="AAFAFR" />
<key-property name="SFATFR" column="SFATFR" type="dao.hibernate.TrimmedString" />
<key-property name="NFATFR" column="NFATFR" />
<key-property name="NRFAFR" column="NRFAFR" />
</composite-id>
<property name="STREFR" column="STREFR" type="dao.hibernate.TrimmedString" />
<property name="NRAZFR" column="NRAZFR" />
<property name="DTUMFR" column="DTUMFR" />
<property name="ORUMFR" column="ORUMFR" />
<property name="BLREFR" column="BLREFR" type="dao.hibernate.TrimmedString" />
<property name="GGFAFR" column="GGFAFR" />
<property name="MMFAFR" column="MMFAFR" />
<property name="SFAPFR" column="SFAPFR" />
.....
<many-to-one name="materiale" class="vo.as400.CMaterialiVO" lazy="false" update="false" insert="false" not-null="true" not-found="ignore" >
<formula>'01'</formula>
<column name="MATEFR"/>
</many-to-one>
<many-to-one name="ordini" class="vo.as400.COrdinirVO" lazy="false" update="false" insert="false" not-null="true" not-found="ignore" >
<column name="STAGFR"/>
<column name="NUORFR"/>
<column name="NURIFR"/>
</many-to-one>
<many-to-one name="modello" class="vo.as400.ModeVO" lazy="false" update="false" insert="false" not-null="true" not-found="ignore" >
<column name="STAGFR"/>
<column name="MODEFR"/>
</many-to-one>
</class>
</hibernate-mapping>
Code:
Criteria crit = session.createCriteria(CFatteVO.class, "vo")
.add(Restrictions.eq("pk.SOFAFT", new Integer(SOFAFT)))
.add(Restrictions.eq("pk.AAFAFT", new Integer(AAFAFT)))
.add(Restrictions.le("MMFAFT", new Integer(MMFAFT))) //<=
.add(Restrictions.le("GGFAFT", new Integer(GGFAFT)))
.add(Restrictions.ne("STREFT", new String("A")))
// .addOrder(Order.asc("pk.NFATFT"))
.setCacheable(true);
I wish to say to Hibernate that don't load some "collection", i must use lazy=false, is it possible?
Devis