开发者

Query in hibernate hbm.xml

开发者 https://www.devze.com 2023-03-24 17:46 出处:网络
Table structure Table1 IDName Type Parentid 123sa124 124rb125 125ta123 If the type is a, I should get the parent id and get the name of that parent id.

Table structure

Table1

ID   Name Type Parentid
123  s     a       124
124  r     b       125
125  t     a       123

If the type is a, I should get the parent id and get the name of that parent id.

How to write the query in hibernate hbm.xml file开发者_如何学Go.. SO that i can map in the mapping bean and display it in frontend. I am using ExtJS grid as frontend and POstgres as backend.

Please help.


SELECT distinct parent.name FROM Parent parent WHERE parent.id in (SELECT table1.Parentid FROM Table1 table1 WHERE table1.Type = 'a');

With this query you'll find all parent names for all entities in table1 with type a.

0

精彩评论

暂无评论...
验证码 换一张
取 消