I am using JpaSpecificationExecutor
for creating custom queries. How do I create a Specification for the following SQL?
select * from employee e, address a where e.id=23415 and e.name="Deepak" and a.city="Leeds";
Java Class :
public static Specification<Employee> searchEmployee(final Map<String,String> myMap) {
return new Specification<Employee>(){
@Override
public Predicate toPredicate(Root<Employee> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
//Need to query two tables Employee and Address
}
}
Here is a test that works
}
Repository looks like this
Entity looks like this
Hope this helps.