I am using Hibernate 2.1.4 with Resin 2.1.12 on MySQL 4.1. The SQL created from Hibernate HQL fails and I can't seem to see any reserved words that I might be using. The tables are FUNCTIONS, USERGROUPS and USERGROUPFUNCTIONS which is used as a join table.
TIA
I am using the following HQL
Code:
SELECT function FROM Function function WHERE function NOT IN
(
SELECT userGroupFunction.function
FROM UserGroupFunction userGroupFunction
WHERE userGroupFunction.userGroup.userGroupId = :userGroupId
)
ORDER BY function.functionName
This creates the following SQL
Code:
select
function0_.FUNCTIONID as FUNCTIONID, function0_.FUNCTIONTYPEID as FUNCTION2_, function0_.FUNCTIONNAME as FUNCTION3_, function0_.
FUNCTIONCODE as FUNCTION4_, function0_.FUNCTIONCLASS as FUNCTION5_, function0_.FUNCTIONDESCRIPTION as FUNCTION6_, function0_.
FUNCTIONURL as FUNCTION7_, function0_.TOPLEVEL as TOPLEVEL, function0_.CREATEBY as CREATEBY, function0_.CREATEON as CREATEON,
function0_.UPDATEBY as UPDATEBY, function0_.UPDATEON as UPDATEON
from FUNCTIONS function0_
where ( function0_.FUNCTIONID NOT IN
(
select usergroupf1_.FUNCTIONID
from USERGROUPFUNCTIONS usergroupf1_
where (usergroupf1_.USERGROUPID=?)
)
)
order by function0_.FUNCTIONNAME
The following is the stack trace that I am seeing:
Code:
java.sql.SQLException: Syntax error or access violation, message from server: "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 'select usergroupf1_.FUNCTIONID from USERGROUPFUNCTIONS usergrou"
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1977)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1163)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1272)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2236)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1555)
at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:87)
at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:800)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:189)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.doList(Loader.java:955)
at net.sf.hibernate.loader.Loader.list(Loader.java:946)
at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:846)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1543)