Ofir Prizat Ofir Prizat - 7 months ago 7
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?
Thanks!

Answer

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, 
tc.terminalServerPort.terminalServer.name, 
tc.terminalServerPort.terminalServer.IPConfig.IPAddress, 
tc.terminalServerPort.portNumber 
from TargetConsole tc where tc.target.id = :targetId order by id asc

Thanks for the help guys!