In our project, we have an entity class Employee
, that looks something like this:
@Entity
class Employee {
...
long travelDistanceAndTimeId;
...
}
We now want to use Spring Data JPA in order to find all employees that have a certain travelDistanceAndTimeId
, so our EmployeeRepository looks like this:
interface EmployeeRepository extends Repository<Employee, Long> {
List<Employee> findByTravelDistanceAndTimeId(long travelDistanceAndTimeId);
}
However, this fails, since Spring Data JPA thinks this method should look for an employee that has a given travelDistance
and a given timeId
, because as per the Spring Data JPA documentation, the and
is treated as a method predicate keyword here.
Is there a way to make Spring Data JPA treat the travelDistanceAndTimeId
as one field, and disable the "AND" method keyword for this query?