'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



Solution 1:[1]

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);

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Diallo Mamadou Pathé