-->
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: WITH keyword does not work
PostPosted: Mon Jul 12, 2010 11:38 am 
Newbie

Joined: Fri Jul 02, 2010 6:27 am
Posts: 5
Hello,

I can not use WITH keyword for extra join conditions. Here is my HQL:
Code:
SELECT request.id FROM Request AS request
LEFT JOIN request.events AS event
WITH event.status='CANCELLED'

and the exception I get:
Code:
org.hibernate.QueryException: unexpected token: WITH [...]
   at org.hibernate.hql.classic.FromParser.token(FromParser.java:105)
   at ...


My hibernate version is 3.2.2.ga. I followed the example from hibernate tutorial so I assume my syntax is correct.
What is happening? Thank you.


Top
 Profile  
 
 Post subject: Re: WITH keyword does not work
PostPosted: Tue Jul 13, 2010 6:11 am 
Newbie

Joined: Fri Jul 02, 2010 6:27 am
Posts: 5
Problem solved.
It was a problem with the Query Translator. The job of the Query Translator is to turn HQL queries into SQL queries. The ClassicQueryTranslatorFactory is the version that was included in Hibernate 2. In Hibernate 3 they created a new Query Translator, the ASTQueryTranslatorFactory. ClassicQueryTranslatorFactory does not know about WITH clause.
Set the Query Translator in the hibernate.properties file:
Code:
#hibernate.query.factory_class org.hibernate.hql.classic.ClassicQueryTranslatorFactory
hibernate.query.factory_class org.hibernate.hql.ast.ASTQueryTranslatorFactory


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.