Ofir Prizat Ofir Prizat - 1 year ago 34
Java Question

What's wrong with this HQL? Where is the missing comma?

I'm getting this hibernate exception:

org.hibernate.QueryException: , expected in SELECT [select tc.id as
id, tc.terminalServerPort.id as terminalServerPortId,
tc.terminalServerPort.terminalServer.name as terminalServerName,
tc.terminalServerPort.terminalServer.ipConfig.ipAddress as
terminalServerIpAddress, tc.terminalServerPort.portNumber as
terminalServerPort from
com.windriver.dsm.labmanagement.data.TargetConsole tc where
tc.target.id = :targetId order by id asc]

Any ideas?


I found the solution.

Apparently the hibernate version which I'm using (hibernate 3) does not allow assigning aliases to associated entities. When I remove those aliases - the query works.

Here is the correct code:

select tc.id, tc.terminalServerPort.id, 
from TargetConsole tc where tc.target.id = :targetId order by id asc

Thanks for the help guys!