将sql查询转换为Hql查询

时间:2016-09-21 17:02:48

标签: sql hibernate hql

请有人帮助将此sql查询转换为Hql查询。或者查询可以作为Hql运行吗?

select p.passport_data, b.unique_number, d.da38 as category
from passport p, dynamic_data d, basic_data b
where b.id = d.basic_data_fk
and p.basic_data_fk = b.id and d.da38 = 'SUBEB'

他们的实体类是:Passport,BasicData,DynamicData

Passport entity class has fields/variables- passportData, basicData
BasicData entity class has fields/variables- id, uniqueNumber
DynamicData entity class has fields/variables- da38

1 个答案:

答案 0 :(得分:1)

试试这个:

select p.passport_data, b.unique_number, d.da38 as category
from Passport p, DynamicData d, BasicData b
where b.id = d.basicData
and p.basicData = b.id and d.da38 = 'SUBEB'

我想在你的DynamicData中存在一个名为basicData的字段(如在Passport类中)