-->
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: Pb on left join
PostPosted: Thu Apr 06, 2006 8:19 am 
Newbie

Joined: Thu Apr 06, 2006 4:02 am
Posts: 3
Hibernate version:
Hibernate 3.05

Name and version of the database you are using:
Oracle 9i

Hi,

I want to make a join on 2 objects which don't have any link in mapping files or in tables but have a functional connection.

This is my HQL request:
Code:
"select  count(*)  from SightAccount as account left join Client as cl on account.coccRadi = cl.code where account.coccPcen in ( 1103, 1112, 5293 )  and cl.type in ( 5, 10, 11 ) "


That's my exception:

Code:
org.hibernate.hql.ast.QuerySyntaxError: unexpected token: on near line 1, column 163 [select  count(*)  from mypackage.SightAccount as account left join Client as cl on account.coccRadi = cl.code where account.coccPcen in ( 1103, 1112, 5293 )  and cl.type in ( 5, 10, 11 ) ]


I searched in Hibernate doc but I didn't find how to write a "left join" request as in SQL. How can I do?

THX.[/code][/b]


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 06, 2006 12:42 pm 
Senior
Senior

Joined: Wed Aug 17, 2005 12:56 pm
Posts: 136
Location: Erie, PA (USA)
The "LEFT JOIN" syntax for HQL only works for associations.

You can get an arbitrary INNER JOIN in HQL as follows: "FROM Object1 obj1, Object2 obj2 WHERE obj1.prop1 = obj2.prop1", but no left join.

Can you create an association? I.E. <many-to-one column="col1" name="assoc1" class="test.Class1" insert="false" update="false" fetch="select">. This way, the association is not fetched unless you attempt to navigate into it OR you explicitly join.

Curtis ...


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