-->
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: hibernate inserts ';' in middle of query
PostPosted: Sat Jan 07, 2012 7:58 am 
Newbie

Joined: Sat Jan 07, 2012 7:53 am
Posts: 2
Hi,

I'm getting an SQLGrammarException because Hibernate inserts a semicolon in the middle of my query. Here's the error:

Code:
Hibernate:
    select
        user0_.USER_ID as USER1_0_,
        user0_.USERNAME as USERNAME0_,
        user0_.PASSWORD as PASSWORD0_,
        user0_.FIRST_NAME as FIRST4_0_,
        user0_.LAST_NAME as LAST5_0_,
        user0_.EMAIL as EMAIL0_,
        user0_.PHONE as PHONE0_,
        user0_.MOBILE as MOBILE0_,
        user0_.GENDER as GENDER0_,
        user0_.AGE as AGE0_,
        user0_.BIRTHDATE as BIRTHDATE0_,
        user0_.EXPIRED as EXPIRED0_,
        user0_.LOCKED as LOCKED0_,
        user0_.ENABLED as ENABLED0_,
        user0_.LAST_UPDATE_TST as LAST15_0_,
        user0_.LAST_UPDATE_USER as LAST16_0_,
        user0_.FAILED_LOGIN_ATTEMPTS as FAILED17_0_
    from
        USER; user0_
    where
        user0_.USERNAME=?
WARN - SQL Error: 1064, SQLState: 42000
ERROR - 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 'user0_ where user0_.USERNAME='admin'' at line 1
org.hibernate.exception.SQLGrammarException: could not execute query
   at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:92)
   at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)


Notice the semicolon after 'USER':
from
USER; user0_
How do I remove this?

I'm using a named query. Here it is:
Code:
  <query name="User.findUserByUsername">
    <![CDATA[
    from User where username = :username
    ]]>
  </query>


I'm using Hibernate 3.6.9.Final with MySQL 5.1.49.

Thanks in advance!


Top
 Profile  
 
 Post subject: Re: hibernate inserts ';' in middle of query
PostPosted: Sat Jan 07, 2012 3:14 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi,
could you please share your User entity and show it's being mapped?

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: hibernate inserts ';' in middle of query
PostPosted: Sat Jan 07, 2012 9:02 pm 
Newbie

Joined: Sat Jan 07, 2012 7:53 am
Posts: 2
nevermind. found the problem. I actually had a semicolon at the table attribute of my mapping ;P


Top
 Profile  
 
 Post subject: Re: hibernate inserts ';' in middle of query
PostPosted: Sun Jan 08, 2012 7:46 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
:-)

_________________
Sanne
http://in.relation.to/


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.