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.  [ 8 posts ] 
Author Message
 Post subject: unexpected token: with
PostPosted: Wed Jan 04, 2006 1:07 pm 
Newbie

Joined: Wed Jan 04, 2006 12:39 pm
Posts: 9
I've read through about everything I can find and can't figure out why it is that I'm getting this error.

I am getting an error that says "unexpected token: with" when executing the following query:

select new
com.solentosystems.nafspronet.beans.DtmlReportItem(user.firstName,
user.lastName, user.emailAddress, user.orgUnit.name,
count(distinct quote.id), count(distinct app.id))
from User user
left join user.applications as app
with app.class =
com.solentosystems.nafspronet.beans.DecreasingTermMortgageLifeApplication
and app.created between :startDate and :endDate
left join user.quotes as quote
with quote.class = com.solentosystems.nafspronet.beans.DecreasingTermMortgageLifeQuote
and quote.quoted between :startDate and :endDate
group by user

Hibernate version:
3.0

Name and version of the database you are using:
MySQL 5.0


Top
 Profile  
 
 Post subject: Hibernate 3.1 gives me...
PostPosted: Wed Jan 04, 2006 2:54 pm 
Newbie

Joined: Wed Jan 04, 2006 12:39 pm
Posts: 9
Hibernate 3.1 gives me a little bit different output. It actually generated a query for me, but the query uses a table alias that isn't actually defined in the query, and I get an error on that. The same exact HQL query above generates the following SQL query in 3.1:

select user0_.firstName as col_0_0_, user0_.lastName as col_1_0_, user0_.emailAddress as col_2_0_, orgunit3_.name as col_3_0_, count(distinct quotes2_.id) as col_4_0_, count(distinct applicatio1_.id) as col_5_0_ from user user0_ left outer join Application applicatio1_ on user0_.id=applicatio1_.user and (case when applicatio1_1_.id is not null then 1 when applicatio1_.id is not null then 0 end=1 and (applicatio1_.created between ? and ?)) left outer join quote quotes2_ on user0_.id=quotes2_.user and (case when quotes2_1_.id is not null then 1 when quotes2_.id is not null then 0 end=1 and (quotes2_.quoted between ? and ?)), orgUnit orgunit3_ where user0_.orgUnitId=orgunit3_.id group by user0_.id


Top
 Profile  
 
 Post subject: Sorry...
PostPosted: Wed Jan 04, 2006 2:55 pm 
Newbie

Joined: Wed Jan 04, 2006 12:39 pm
Posts: 9
I forgot to post the error it is displaying now:

13:54:42,655 WARN JDBCExceptionReporter:71 - SQL Error: 1109, SQLState: 42S02
13:54:42,655 ERROR JDBCExceptionReporter:72 - Unknown table 'applicatio1_1_' in on clause


Top
 Profile  
 
 Post subject: Query Outcome
PostPosted: Wed Jan 04, 2006 3:31 pm 
Newbie

Joined: Wed Jan 04, 2006 12:39 pm
Posts: 9
I renamed the incorrect table alias in the query, and the query executed fine, so it looks like Hibernate is generating incorrect SQL. Does anyone know of any reason why this would be happening?


Top
 Profile  
 
 Post subject: Is it Hibernate 3.0
PostPosted: Wed Jan 04, 2006 3:44 pm 
Newbie

Joined: Thu Dec 15, 2005 1:21 pm
Posts: 1
Is query executing fine in Hibernate 3.0?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 04, 2006 3:46 pm 
Newbie

Joined: Wed Jan 04, 2006 12:39 pm
Posts: 9
No. In Hibernate 3.0 I got the initial error that I posted, basically saying that the query could not be parsed. Then, in 3.1 the query is parsed but incorrect SQL is generated.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 04, 2006 4:26 pm 
Newbie

Joined: Wed Jan 04, 2006 12:39 pm
Posts: 9
Sorry, but I got a bit more information about the issue. It only happens when the app.class and quote.class clauses are in the HQL query. If I remove those, the query runs fine.

Unfortunately, I need to be able to filter out all but the DecreasingTermMortgageLifeApplication and Quote objects.

I know I could use a filter... and I'm going to right now, but I still am wondering if I should be able to do this directly in HQL.


Top
 Profile  
 
 Post subject: Still Not Solved
PostPosted: Thu Jan 05, 2006 11:44 am 
Newbie

Joined: Wed Jan 04, 2006 12:39 pm
Posts: 9
I can't really use a filter, because I need to get a count on the attribute that I would have filtered. So, does anyone have any idea why my query isn't working?


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