如何在命名查询中编写联接?

时间:2018-02-27 15:03:59

标签: mysql database hibernate

我尝试编写此查询,但它会抛出异常

@NamedQueries({
@NamedQuery(name = "doctor_searchDoctor", 
              query= "SELECT d FROM Doctor d "
                    + "WHERE ((d.englishName = :P_NAME_EN OR :P_NAME_EN = '-1' ) "
                    + "AND d.id IN (select c.doctorId from Clinic c "
                    + "JOIN DoctorSpecializations s "
                    + " where ((c.cityId = :D_CITY_ID OR :D_CITY_ID = -1 ) AND (s.specializationId = :D_SPECIALIZATION_ID OR :D_SPECIALIZATION_ID = -1))))"

  ),
})

在调试代码时我发现异常

  

org.hibernate.HibernateException:命名查询中的错误:doctor_searchDoctor

1 个答案:

答案 0 :(得分:1)

<property expression="$ctx:tran_id" name="tran_id" scope="default" xmlns:m0="http://ws.wso2.org/dataservice"/>

之后)遗失了一个WHERE ((d.englishName blah