-->
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.  [ 1 post ] 
Author Message
 Post subject: child set gets loaded even though lazy attribute set to true
PostPosted: Thu Sep 15, 2005 5:26 pm 
Newbie

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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.