-->
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: 'on' clause usage - Hibernate dynamic query translator
PostPosted: Thu Mar 30, 2006 4:49 pm 
Newbie

Joined: Fri Mar 03, 2006 2:11 pm
Posts: 16
Hibernate version: 3.1

Name and version of the database you are using: DB2 Version 8.x
When I try to use Dynamic query translator with the following SQL query I get errors:
select acc.username from Account acc join Profile prof on acc.userid=prof.userid

It is failing at 'ON' clause and I do not see any error in SQL syntax. Please note that all classes used in thsi SQL query are available in the workspace/project


Full stack trace of any exception that occurs:
org.hibernate.hql.ast.QuerySyntaxException: unexpected token: on near line 1, column 74 [select acc.username from com.ibm.hibernate.Account acc join Profile prof on acc.userid=prof.userid

]
Caused by:
org.hibernate.hql.ast.QuerySyntaxException: unexpected token: on near line 1, column 74 [select acc.username from com.ibm.hibernate.Account acc join Profile prof on acc.userid=prof.userid

]


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 31, 2006 2:39 am 
Beginner
Beginner

Joined: Fri Oct 28, 2005 7:11 am
Posts: 20
use 'with' clause


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 03, 2006 12:12 pm 
Newbie

Joined: Fri Mar 03, 2006 2:11 pm
Posts: 16
tbech wrote:
use 'with' clause


When I use 'with' clause I get this error message:
Caused by:
org.hibernate.hql.ast.QuerySyntaxException: Path expected for join! [Select act.firstname from com.ibm.hibernate.Account act join Profile prof with act.userid=prof.userid]

Thank you


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 03, 2006 1:28 pm 
Expert
Expert

Joined: Wed Apr 06, 2005 5:03 pm
Posts: 273
Location: Salt Lake City, Utah, USA
A normal join would look something like this:

Code:
select acc.username from Account acc join acc.profile prof

(assuming Account has an association to Profile named 'profile')

If you want to have extra join conditions, you can use 'with', but as far as I know, you can't join across two unassociated classes. The association must be there in the mapping files (e.g. Account.profile). And you must use that association in the join ( 'join acc.profile', not just 'join Profile').

_________________
nathan


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.