-->
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: Criteria Query, component and FetchMode.EAGER
PostPosted: Thu Feb 24, 2005 1:22 pm 
Newbie

Joined: Fri Mar 26, 2004 8:51 am
Posts: 6
Hi all.
We have a MileageVoucher class, one of its attributes is a Audit component. This component has two attributes one of which, user, is a reference to a InfoUser class. This InfoUser class has an attribute principalOffice that is a reference to the Office class. We are making a consultation using Criteria and we would need that the attribute principalOffice is initialized as is obtained using the FetchMode.EAGER. Exists that possibility?

Hibernate version:
2.1.5
We areusing Spring+Hibernate combination.
Mapping documents:
MileageVoucher mapping:
<hibernate-mapping package="com.sancorseguros.nova.cashbank.domain">
<class name="MileageVoucher" table="nvo.MileageVoucher">
<id name="mileageVoucherID" type="integer" unsaved-value="null" >
<generator class="identity"/>
</id>
<property name="voucherDate"/>
<property name="voucherNumber"/>
<many-to-one name="client" class="com.sancorseguros.nova.client.domain.Client" column="clientID" cascade="none"/>
<many-to-one name="destinationNote" class="com.sancorseguros.nova.general.domain.Note" column="destinationNoteID" cascade="none"/>
<many-to-one name="motiveNote" class="com.sancorseguros.nova.general.domain.Note" column="motiveNoteID" cascade="none"/>
<many-to-one name="accompanistNote" class="com.sancorseguros.nova.general.domain.Note" column="accompanistNoteID" cascade="none"/>
<many-to-one name="affectedUnit" class="AffectedUnit" column="affectedUnitID" cascade="none"/>
<property name="departureDate"/>
<property name="departureKM"/>
<property name="arrivalDate"/>
<property name="arrivalKM"/>
<many-to-one name="loan" class="InvestLoan" column="loanID" cascade="none"/>
<property name="currencyID"/>
<property name="loanCancelAmount"/>
<property name="payAmount"/>
<many-to-one name="mileageVoucherStatus" class="MileageVoucherStatus" column="mileageVoucherStatusID" cascade="none"/>
<many-to-one name="authorizationUser" class="com.sancorseguros.nova.general.domain.InfoUser" column="authorizationUserID" cascade="none"/>
<property name="authorizationDate"/>
<property name="annulDate"/>
<property name="payID"/>
<set name="mileageVoucherDetails" lazy="true" cascade="all" inverse="true">
<key column="mileageVoucherID"/>
<one-to-many class="MileageVoucherDetail"/>
</set>
<component name="audit" class="com.sancorseguros.nova.general.domain.Audit">
<many-to-one name="user" class="com.sancorseguros.nova.general.domain.InfoUser" column="userID" cascade="none"/>
<property name="loadDate"/>
</component>
</class>
</hibernate-mapping>
InfoUser mapping:
<hibernate-mapping package="com.sancorseguros.nova.general.domain">
<class name="InfoUser" table="nvo.Users" proxy="InfoUser" >
<id name="userID" type="integer" unsaved-value="null" >
<generator class="identity"/>
</id>
<property name="userName"/>
<many-to-one name="principalOffice" class="com.sancorseguros.nova.general.domain.Office" column="officeID" cascade="none"/>
<many-to-one name="client" class="com.sancorseguros.nova.client.domain.Client" column="clientID" cascade="none"/>
</class>
</hibernate-mapping>
Office mapping:
<hibernate-mapping package="com.sancorseguros.nova.general.domain">
<class name="Office" table="nvo.TabOffice" proxy="Office">
<id name="id" column="officeID" type="integer" unsaved-value="null" >
<generator class="identity"/>
</id>
<property name="descript"/>
</class>
</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():
Criteria criteria = (Criteria)getHibernateTemplate() .execute(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException {
return getHibernateTemplate().createCriteria(session, MileageVoucher.class);
}
});
List vouchers = null;
try {
criteria.setFetchMode("client", FetchMode.EAGER);
if(param.containsKey("clientID")) {
Integer clientID = (Integer)param.get("clientID");
criteria.add(Expression.eq("client.clientID", clientID));
}
vouchers = criteria.list();
} catch (HibernateException e) {
throw this.convertHibernateAccessException(e);

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 25, 2005 12:08 pm 
Newbie

Joined: Fri Mar 26, 2004 8:51 am
Posts: 6
Anybody can help me????. There is no sufficient information like obtaining an answer?.


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.