-->
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: HQL select statement fails "could not execute query"
PostPosted: Wed Jul 15, 2009 2:29 am 
Newbie

Joined: Mon Jun 25, 2007 3:06 pm
Posts: 5
Hi forum,

I have the following problem:
I create the following query:

Code:
String q = "select new Guest(g.id, g.firstName, g.lastName, g.invitations) from Guest g";
         List list = getHibernateTemplate().find(q);


Guest has the appropriate constructor. The problem comes up with g.invitations where g.invitations is a onetomany relation.

Hibernate throws an exception "could not execute query"
Code:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'as col_3_0_ from net_guestmanager_guests guest0_ inner join net_guestmanager...' at line 1


and produces the following SQL
Code:
select guest0_.id as col_0_0_, guest0_.first_name as col_1_0_, guest0_.last_name as col_2_0_, . as col_3_0_
from net_guestmanager_guests guest0_ inner join net_guestmanager_invitation_list invitation1_ on guest0_.id=invitation1_.guest_fk




I have no idea what went wrong. I try to search for similar things but did not find whether it is possible at all to do such a query.

Does anybody has an idea?
Thanks in advance
John


Top
 Profile  
 
 Post subject: Re: HQL select statement fails "could not execute query"
PostPosted: Wed Jul 15, 2009 3:44 am 
Newbie

Joined: Sun Aug 24, 2008 3:21 pm
Posts: 8
See the generated SQL. The systax is wrong (there is only a dot before your last alias ". as col_3_0_" ).
Maybe your column "g.invitations" isn't correct?

hope, it helps


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.