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!