-->
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.  [ 3 posts ] 
Author Message
 Post subject: HQL inner join on a primitive type
PostPosted: Sun Jul 16, 2006 4:42 pm 
Newbie

Joined: Fri Jul 07, 2006 9:51 am
Posts: 9
Hibernate version:3.1.3

Hello everybody :

In HQL, is there a possibility to do a join in on 2 entities (classes) without one being member of the other ?

I looked through the Hibernate examples and seems that always the examples have something like "from Product p inner join fetch p.categories"

I only need to show a product having a certain category without having Category a data member of product.

Well, <join> tag would have made the business but it can only join on the primary key of the first table...

Thank you
Lucian


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 16, 2006 6:20 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
You can use theta-style "cross" joins to do this:
Code:
select a.val1, b.val2
from A a, B b
where a.JoinCol = b.JoinCol
Note that <join> does not require joining on the primary key of the first table: use <key column="colInTable2" property-ref="propInEntity1"/> to use a non-ID property.

_________________
Code tags are your friend. Know them and use them.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 21, 2006 2:38 pm 
Newbie

Joined: Fri Jul 07, 2006 9:51 am
Posts: 9
Thank you for your reply.

However

http://opensource.atlassian.com/project ... se/HHH-551
http://opensource.atlassian.com/project ... e/HHH-1829


the property-ref is not taken into account in the join tag.


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