-->
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.  [ 3 posts ] 
Author Message
 Post subject: Fetching lazy associations
PostPosted: Wed Apr 04, 2007 9:34 am 
Newbie

Joined: Mon Mar 26, 2007 5:26 am
Posts: 10
Hey all

I am using the following HQL statement to retrieve a movie and its 'tags' collection.


from Movie m
inner join fetch m.tags


The problem is that when the collection is loaded all of the associated objects of the collection also are loaded.

Movie.hbm.xml
<set name="tags" cascade="all">
<key column="movie_id" />
<one-to-many class="com.example.model.Tag" />
</set>

Tag.hbm.xml
<many-to-one
name="user"
column="user_id"
not-null="true"
/>

<many-to-one
name="movie"
column="movie_id"
not-null="true"
/>

What I don't want is Hibernate loading the user and movie properties for the 'tag' collection when issuing the HQL statement, is it possible to only populate certain properties of associated collections?

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 04, 2007 10:14 am 
Regular
Regular

Joined: Wed May 05, 2004 3:41 pm
Posts: 118
Location: New Jersey,USA
Trying making "user" and "movie" as lazy collections:

<many-to-one
name="user"
column="user_id"
not-null="true"
lazy="true"
/>

_________________
--------------
Don't forget to Rate the post


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 04, 2007 10:40 am 
Newbie

Joined: Mon Mar 26, 2007 5:26 am
Posts: 10
But that's not even a valid argument since they are lazy by default.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.