-->
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.  [ 3 posts ] 
Author Message
 Post subject: Help with Criteria
PostPosted: Fri Oct 07, 2005 4:09 am 
Regular
Regular

Joined: Thu Feb 24, 2005 2:34 pm
Posts: 80
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


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 10, 2005 11:22 am 
Regular
Regular

Joined: Sat Aug 28, 2004 4:15 pm
Posts: 61
Look at http://www.hibernate.org/hib_docs/v3/re ... ml_single/

Section 16.5 talks about dynamic association fetching. It allows you to specify your load rules in the criteria.

Joe

_________________
Joe W


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 14, 2005 10:06 am 
Regular
Regular

Joined: Thu Feb 24, 2005 2:34 pm
Posts: 80
Thank you very much
Devis


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