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 loading problems (my objects still getting loaded)
PostPosted: Fri Sep 01, 2006 10:20 am 
Newbie

Joined: Fri Sep 01, 2006 10:04 am
Posts: 1
Hello,

Using Hibernate 3.1

I have a problem to lazily load a collection. I have read the Hibernate Documentation and also Hibernate in Action (for Hibernate 2.0).

In the book and also the documentation I read that to lazily load a collection you need to set the flag lazy=true. I have done this, however for some reason my system still shows me Sql to load the objects that should only be loaded lazily!

I have an object representing a Case. The Case object then has a List object that contains Compenents. I have done the hbm.xml file for Case as follows:

Code:
<hibernate-mapping>
   <class>
      ...
        <list
            name="newsletters"
            lazy="true"
            inverse="true"
            cascade="all"
            >

            <key column="resource">
            </key>

      <index column="id" />

      <one-to-many
         class="com.sixpmodel.cvmanager.common.impl.BaseNewsletter"
         />

      </list>
      ...
   </class>
</hibernate-mapping>

However as already said, Hibernate is still loading me the childreen components. In my database I have a table called Case that has a one to many relationship with another table called Components. This is what I would like to ammulate in my objects. However I do not want to load all the Components in Case when I do not need them!

Can someone please tell me what I am doing wrong.

Thank You for all help.


Top
 Profile  
 
 Post subject: lazy loading problems (my objects still getting loaded)
PostPosted: Fri Sep 01, 2006 2:34 pm 
Newbie

Joined: Tue Sep 27, 2005 5:44 pm
Posts: 13
Are you using simple session.load(Case.class, <Long>) or hsql (hibernate sql)? If you're using hsql and join to the child object, they get loaded.

btw - you shouldn't have to specify lazy=true as that's the default in 3.x. HIA was for 2.x as you mentioned.


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.