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: SetMaxResults on DetachedQuery
PostPosted: Mon Jun 16, 2008 2:07 am 
Newbie

Joined: Wed May 28, 2008 3:17 am
Posts: 10
nHibernate version: 1.2.1 GA
Name and version of the database you are using: Sql2k

Is it possible to set the max results on a detached query (or subquery)?

For example, say I have two tables: Person & Payment. I want to get the the Person details for person who made the latest Payment. Code would be something like:

Code:
DetachedCriteria dc = DetachedCriteria.For(typeof(Payment));
dc.AddOrder(new Order("PaymentDateTime", false));
dc.SetProjection(Projections.Property("PersonId"));

ICriteria c = session.CreateCriteria(typeof(Person));
c.Add(Subqueries.PropertyIn("PersonId", dc));


(Yes, I know there are probably better ways of constructing the query, but due to reasons I cant go into here, I can't make a join - I have a to project & Subquery this way!)

I want to add the following line, but it isn't acceptable nHibernate:

Code:
dc.SetMaxResults(1);


Any ideas?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 16, 2008 11:17 am 
Senior
Senior

Joined: Thu Jun 21, 2007 8:03 am
Posts: 127
Location: UK
Hi,

This is curiously missing from the 1.2 version of NHibernate. But it is in version 2.0.

If you don't mind the 'alpha' status, you could consider upgrading to 2.0 (it's very stable despite the name).

Regards,
Richard


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.