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: eager loading with fetch attribute on sets
PostPosted: Mon Nov 10, 2008 3:09 am 
Newbie

Joined: Mon Nov 10, 2008 12:30 am
Posts: 1
Location: Ho Chi Minh
(NHibernate 2.0.1 GA)

I am trying to setup eager loading for one of my collections (simple one-to-many) and am having some problems.

My set is defined within an entity called Category as follows: -
Code:
<set name="CategoryValues" inverse="true" fetch="join" >
      <key column="CategoryID" />
      <one-to-many class="CategoryValue" />
    </set>

I can load a Category class but if I try to access the CategoryValues set after the session is closed, I get the following error: -
Code:
failed to lazily initialize a collection, no session or session was closed

In reading Hibernate In Action, fetch="join" should disable lazy loading but it does not appear to in this case. I'm not sure if this is a difference between Hibernate and NHibernate.

I can add the lazy="false" attribute and eager loading works. However, even though I have fetch="join", the SQL executed is a series of SELECT statements, one for each CategoryValue. I.e. not a join.

I have the same issue using fetch="join" on a many-to-one property.


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.