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: Are theta-style joins supported in NHib?
PostPosted: Tue Jan 29, 2008 5:01 pm 
Regular
Regular

Joined: Thu Nov 30, 2006 10:48 am
Posts: 59
I need to use a theta-style join for two objects that do not have their relationship mapped in the class mappings (in this post, I won't get into the reason why I need this). The book, Hibernate in Action, shows that Hibernate supports theta-style joins and I'm hoping that nHib does, too, but I'm getting an error: outer or full join must be followed by path expression

Here is the code:

IQuery q = _session.CreateQuery("select e from CEvent e inner join PhysicalNetworkDevice pnd WHERE e.NetworkElementID = pnd.ID AND e.NetworkElementTypeName = 'Device' AND e.ID = :id");

q.SetInt32("id", iID);
System.Collections.IList list = q.List();
cevent = (CEvent)list[0];

Anything I'm doing wrong?

Thanks,
Bill

_________________
metazone


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 29, 2008 7:17 pm 
Expert
Expert

Joined: Mon Nov 26, 2007 2:29 pm
Posts: 443
metazone,

Theta-joins are those joins which are expressed exclusively in the WHERE clause.
Your query with theta joins would look:

Code:
select e
from CEvent e, PhysicalNetworkDevice pnd
WHERE e.NetworkElementID = pnd.ID
AND e.NetworkElementTypeName = 'Device' AND e.ID = :id"


in your example you were mixing normal and theta join syntaxes

_________________
Gonzalo Díaz


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 30, 2008 10:24 am 
Regular
Regular

Joined: Thu Nov 30, 2006 10:48 am
Posts: 59
Thanks very much -- this worked. I guess I'm a little confused with respect to the syntax for normal vs. theta-style joins

_________________
metazone


Top
 Profile  
 
 Post subject: what about outer join
PostPosted: Mon Aug 11, 2008 2:02 am 
Newbie

Joined: Fri Aug 08, 2008 9:38 am
Posts: 3
This solves problem only for inner join. What about outer join(left/right/full)?

I have a requirement to join two tables unrelated w.r.t. hibernate.
I want something like:
Code:
"select a,b from A a full join B b on a.col1=b.col1"

I want Object[] where Object[1] could be null when no links exist and viceversa.
I cant do this with HQL.


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.