简体   繁体   中英

How can we write JPA query for below SQL query

how to write jpa query for below sql without using native sql query

select * from emp where emp_id=123 and (emp_name="ABC" OR emp_name is NULL) order by salary

If we say

A and (B or C) <=> (A and B) or (A and C)

then you query must look like this one below

Employee findByEmp_idAndEmp_nameOrEmp_idAndEmp_nameIsNullOrderBySalary(Long empId, String empName);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM