Ofir Prizat Ofir Prizat - 2 years ago 75
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?

Answer Source

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!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download