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>
|