-->
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.  [ 4 posts ] 
Author Message
 Post subject: Nhibernate criterias
PostPosted: Thu Jul 24, 2008 11:32 am 
Newbie

Joined: Tue Apr 08, 2008 11:27 am
Posts: 3
Hibernate version: 2.0 Alpha

Name and version of the database you are using: MSSQL 2005

How to create select like - "SELECT ... FROM Table1, Table2" using Nhibernate Criterias(in "from" clause tables must be separated with ",")


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 24, 2008 12:01 pm 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
If you don't have an association between the two, you can't. If you only want to select one ot the tables, a subquery might work. have a look at this post:

http://forum.hibernate.org/viewtopic.php?t=988552&highlight=subquery+exists

_________________
--Wolfgang


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 25, 2008 3:07 am 
Newbie

Joined: Tue Apr 08, 2008 11:27 am
Posts: 3
generated query should exactly equal

SELECT p1.*
from Category as p1, Category as p2
where p1.LeftSide between p2.LeftSide and p2.RightSide
GROUP BY [p1].[Id]

but in NHiberante sources I found that "from" clause generation occurs with adding "on" expression


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 29, 2008 2:02 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
With criterias you need an association between the two entities. If you have one, you can use criterias and the resulting sql contains the necessary join (where the "on" comes from). If you don't have an association, you can't use criterias.

_________________
--Wolfgang


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.