-->
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: Hibernate is loading collections even though lazy=true???
PostPosted: Sat Jul 31, 2004 4:33 pm 
Beginner
Beginner

Joined: Tue Aug 26, 2003 4:19 pm
Posts: 42
I have a one to many association from Eventtype to Event, relationship mapped (using Middlegen) as follows:

From Eventtype to Event
Code:
   
<!-- bi-directional one-to-many association to Event -->
    <set
        name="events"
        lazy="true"
        inverse="true"
      cascade="none"
    >
        <key>
            <column name="eventtypeid" />
        </key>
        <one-to-many
            class="com.hibernate.Event"
        />
    </set>


From Event to Eventtype
Code:
        <many-to-one
            name="eventtype"
            class="com.hibernate.Eventtype"
            not-null="true"
            >
            <column name="eventtypeid"/>
        </many-to-one>


I'm retrieving the eventtypes with a simple find():

List eventtypes = session.find("from Eventtype as eventtype");

When I run this I get a huge tree of objects and sub-objects. Do I have some problem with the mapping? Is there some application-level config setting that overrides my lazy loading setting in the hbm?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 02, 2004 11:04 am 
Beginner
Beginner

Joined: Thu Feb 26, 2004 11:32 am
Posts: 32
You also have to specify lazy="true" in Event.hbm.xml at the class level
and specify a proxy.you can specify the same class as a proxy for itself.checkout hibernate documentation

<class
name="Event"
table="EVENT_TABLE"
lazy="true"
proxy="Event"
>

splash


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.