如何将嵌套SQL转换为HQL

Bhu*_*han 12 java hibernate hql

我是Hibernate和HQL的新手.我想在HQL中编写更新查询,其SQL等效项如下:

update patient set 
      `last_name` = "new_last", 
      `first_name` = "new_first" 
where id = (select doctor_id from doctor 
            where clinic_id = 22 and city = 'abc_city');
Run Code Online (Sandbox Code Playgroud)

doctor_id是PK, doctor并且是FK和PK patient.有一对一的映射.

相应的Java类是Patient(具有字段lastName,firstName,doctorId)和Doctor(具有字段doctorId).

任何人都可以告诉我们上面的SQL查询的HQL等价物是什么?

非常感谢.

mcy*_*cin 13

String update = "update Patient p set p.last_name = :new_last, p.first_name = :new_first where p.id = some (select doctor.id from Doctor doctor where doctor.clinic_id = 22 and city = 'abc_city')";
Run Code Online (Sandbox Code Playgroud)

如果检查规范,可以弄清楚如何短语hql查询.您可以在那里找到有关子查询的部分.