-->
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: lazy collection fetching at runtime
PostPosted: Tue Sep 18, 2007 10:22 am 
Newbie

Joined: Mon Aug 14, 2006 11:47 am
Posts: 8
Hi @all

I have a special requirment for fetching collections lazy at runtime. Situation: A Class: CodeTypes has zero or n Classes: CodeValues.

As default in the mapping file, of CodeType, the lazy attribute is "false" on the set (see below).

Now i have a special case: how i can load a CodeType at Runtime without loading all his CodeValues. Is this possible ?

I have tried the following code:

session.createCriteria(CodeType.class)
.setFetchMode("CodeType.dcaCodevalues", FetchMode.LAZY)
.add( Restrictions.eq("id", type.getId()) )
.uniqueResult();

but this codes works not, all CodeValues are loaded also.

Thanks for all inputs !


Hibernate version:
3.0
Mapping documents:
<hibernate-mapping package="xx.xxx.xx.administrator.dto">
<class name="CodeType" table="CODETYPE" schema="...">
<id name="pky" type="long">
<column name="PKY" precision="22" scale="0" />
<generator class="increment" />
</id>
<set name="dcaCodevalues" inverse="true" lazy="false" cascade="all">
<key>
<column name="CODETYPE_FKY" precision="22" scale="0" not-null="true" />
</key>
<one-to-many class="CodeValue" />
</set>
</class>
</hibernate-mapping>


<hibernate-mapping package="xx.xxx.xx.administrator.dto">
<class name="CodeValue" table="CODEVALUE" schema="...">
<id name="pky" type="long">
<column name="PKY" precision="22" scale="0" />
<generator class="increment" />
</id>
<many-to-one name="dcaCodetype" class="CodeType" fetch="select" not-null="true" cascade="none">
<column name="CODETYPE_FKY" precision="22" scale="0" not-null="true" />
</many-to-one>
</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject: any tips ???
PostPosted: Tue Sep 25, 2007 5:53 am 
Newbie

Joined: Mon Aug 14, 2006 11:47 am
Posts: 8
any tips ???


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.