Joined: Thu Sep 15, 2005 4:58 pm Posts: 1 Location: CA
|
A sql query gets called to load the children set irrespective of the value of lazy attribute (i've tried true and false, and it makes no difference). Please let me know how can i avoid loading the children set. I do not need to load them and want to avoid making the unnecessary sql call.
PS: I'm on hibernate version 2.0.
-- This is the relevant xml from Parent.hbm.xml
-----------------------------------------------------------------------------------
<set
name="children"
lazy="true"
inverse="true"
cascade="all-delete-orphan"
>
<key>
<column name="PARENT_ID" />
</key>
<one-to-many
class="com.Child"
/>
</set>
-----------------------------------------------------------------------------------
-- This is the relevant xml from Child.hbm.xml
-----------------------------------------------------------------------------------
<composite-id name="id" class="com.Child">
<key-property
name="parentId"
column="PARENT_ID"
type="java.lang.Long"
length="10"
/>
<key-property
name="childId"
column="ID"
type="java.lang.Long"
length="10"
/>
</composite-id>
<many-to-one
name="parent"
class="com.Parent"
update="false"
insert="false"
outer-join="false"
>
<column name="PARENT_ID" />
</many-to-one>
-----------------------------------------------------------------------------------
-- This is the code that is called to load the parent object.
-----------------------------------------------------------------------------------
Session session = HibernateHelper.getSession();
Criteria crit = session.createCriteria(Parent.class).add(
Expression.eq("id", id));
parent = (Parent)crit.uniqueResult();
System.out.println("Found Parent with the Id = " + id);
-----------------------------------------------------------------------------------
|
|