-->
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: criteria fetchmode
PostPosted: Wed Jul 19, 2006 12:08 pm 
Newbie

Joined: Fri Jun 30, 2006 8:37 am
Posts: 8
Hi,

can anyone assist with the following.

I have the following relationship set up within NHibernate:

I have a top-level 'notification' object.

under the 'notification' I have a NotificationPrimaryAddressee object (one to many)

under the NotificationPrimaryAddressee I have a user object (one to many)

I want to use a criteria/fetchmode expression to return all Notification Primary Addressee's and Users under the main notification object, but unfortunately the code I am using only returns the top-level Notification object.

Here's my code:-

ICriteria criteria = session.CreateCriteria(typeof(DataModel.Notification));
criteria.AddOrder(Order.Desc("NotificationDate") );
criteria.CreateAlias("NotificationPrimaryAddressees","A");
criteria.CreateAlias("A.User","AU");
criteria.SetFetchMode("A", FetchMode.Join);
criteria.SetFetchMode("AU", FetchMode.Join);
criteria.SetResultTransformer(CriteriaUtil.DistinctRootEntity);


I have also tried the above without aliases, but that doesn't seem to make any difference. Can anyone please tell me what I am doing wrong?


Top
 Profile  
 
 Post subject: Further information
PostPosted: Thu Jul 20, 2006 7:18 am 
Newbie

Joined: Fri Jun 30, 2006 8:37 am
Posts: 8
In relation to the above problem, I have discovered that, if I run through the application in debug mode, the criteria expresssions work. However, if I run the criteria expresssion in normal mode the underlying sub-object collections (e.g. NotificationPrimaryAddressees) aren't populated. (I've even put in a couple of system.thread.sleep commands, but this doesn't rectify the problem)

Has anyone got any ideas what could be causing this behaviour?


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.