-->
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: No logic in lazy load behavior
PostPosted: Fri Mar 13, 2009 8:13 am 
Newbie

Joined: Sun Sep 21, 2008 4:10 pm
Posts: 3
You would expect that this code would load pages.Culture[localCulture] every time it executes. Well NHibernate does not think so and instead loads pages.Culture[localCulture] only ONCE in session. So due to lazy loading everything else in pages.Culture will NEVER get loaded as trying to access something like pages.Culture[2] will just throw an exception of trying to access an object which is null. Yeah you could try loading pages.Culture[2].Whatever to try to force NHibernate load it from database, but if it doesn't exist you just end up with another exception. Yet if the join returns 0 results NHibernate will not load the object at all (at is should), but if there is 1 result (or more) it will just fetch you the query it executed earlier.

I don't see any logic in such behavior. If I explicitly execute a query to load that exact part of collection it should be loaded, not just checked for existance (as of what it does on second execution of the same query).

IList pages = DBSession.CreateQuery("select distinct from DBMap.Pages t1 " +
"join fetch t1.Locales t2 " +
"where t1.System = 0 and t2.Culture = " + localCulture +
" order by Title")
.List();


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.