-->
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: lazily loading collection
PostPosted: Tue Oct 19, 2010 9:20 am 
Beginner
Beginner

Joined: Thu Nov 12, 2009 1:57 am
Posts: 22
Suppose I have following class,

Code:

public class Event {
private Long id;
private String name;
private Date startDate;
private int duration;
private Set speakers;
private Set attendees;
private Location location;
}


Code:

<class name="com.manning.hq.ch05.Event" table="events">
        <id name="id" type="long" unsaved-value="null">
            <generator class="native"/>
        </id>
        <property name="name" type="string" length="100"/>
        <property name="startDate" column="start_date"
                  type="date"/>
        <property name="duration" type="integer"/>
        <many-to-one name="location" column="location_id"
                     class="com.manning.hq.ch05.Location"/>
        <set name="speakers" cascade="all">
            <key column="event_id"/>
            <one-to-many class="com.manning.hq.ch05.Speaker"/>
        </set>
        <set name="attendees" cascade="all">
            <key column="event_id"/>
            <one-to-many class="com.manning.hq.ch05.Attendee"/>
        </set>
    </class>



I load Event from session object. Now when i use getSpeaker(), hibernate would lazily load the speaker collection(assuming lazy is true by default).

I wanted to understand the following concept:

When I do event.getSpeaker(), which give me a set containing Speaker, is the Speaker object populdated with data, or the stubs are loaded initially and then when i make call to Speaker method the object is actually populdated


Top
 Profile  
 
 Post subject: Re: lazily loading collection
PostPosted: Tue Oct 19, 2010 9:30 am 
Senior
Senior

Joined: Fri Oct 08, 2010 8:44 am
Posts: 130
This is one strange question. Of course the stubs are made first. This is why it is called lazy loading. I suggest you to read Hibernate manual.


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.