-->
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: [v2] How to "Outer Join" without HBM Declaration.
PostPosted: Mon Aug 01, 2005 10:40 am 
Newbie

Joined: Mon Aug 01, 2005 8:53 am
Posts: 2
Hibernate version: 2


Hi,

I would like to write a left outer join query, but not based on relations declared in HBM mappings, i.e. there is no collection or so to represent that relation.

SQL I would write :
Code:
select ...
from A a
left outer join B b on b.id = a.b_id


In HQL doc, I am told to write :
Code:
from A a left outer join a.b b

and it expects me to declare a many-to-many (or many-to-one) in a.hbm telling about relation between a and b.

Unfortunatly, I can't touch a.hbm, it's part of some external product we use.

I wish I could tell HQL how to make the join, without him looking in the HBM file. Is it possible ?

Note : if I can't use the outer join keyword, with Oracle I would write something like :
Code:
select ... from A a, B b where b.id = a.b_id (+)

but I guess there is no such feature in hibernate since it's pure Oracle syntax. or ?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 01, 2005 10:48 am 
Expert
Expert

Joined: Thu Dec 04, 2003 12:36 pm
Posts: 275
Location: Bielefeld, Germany
You can solve your problem using native SQL.
Code:
sess.createSQLQuery(...)

http://www.hibernate.org/hib_docs/v3/re ... -nativesql
http://www.hibernate.org/hib_docs/v3/re ... /#querysql

Here you'll also find some information:
http://forum.hibernate.org/viewtopic.php?t=945308

Best regards
Sven


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.