Select only one row by using SetMaxResult to one, thats probarbly the fastest way to go about it. You query would still touch every single row in database.
sess.CreateQuery("select Id from Product p where p.category = 5").SetMaxResult(1) -- Jakob Tikjøb Andersen +45 25 277 105 On Thu, Aug 6, 2009 at 1:30 AM, Marvin Massih <marvin.mas...@googlemail.com>wrote: > > Hi, > > I'd like to be able to write something like this: > > Exists( "from Product p where p.CategoryID = 5" ); > > This should be translated to something like this: > > select 1 from PRODUCT where CATEGORY_ID = 5; > > So I don't want to actually want to fetch any data, I just want to > know if there is matching data in the database. > What would be the best way to do this? > > Is there a better way than using count() or selecting ID's? > > Thanks, > Marvin > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---