What happened to this HQL? Where is the missing comma?

I get this hibernation 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? Thank!

+4
source share
3 answers

I have found a solution.

Apparently the hibernate version I'm using (hibernate 3) does not allow aliases to be assigned to related objects . When I delete these aliases, the request 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 helping the guys!

+1
source

Even when I narrow the HQL to the minimum I still get that exception - , expected in SELECT [select tc.id as id from com.windriver.dsm.labmanagement.data.TargetConsole as tc]

Shouldn't you write like that?

[select tc.id as id from com.windriver.dsm.labmanagement.data.TargetConsole tc]

Why do you write aswhen providing aliases to a table?

+1
source

hibernate sessionFactory, .

hibernate.query.factory_class = org.hibernate.hql.ast.ASTQueryTranslatorFactory
+1

Source: https://habr.com/ru/post/1545028/


All Articles