How to use object as parameter in Spring JPA query

 Let's assume you have a class called Customer like this:

public class Customer {

    private String name;

    private String phoneNumber;

    private Integer age;

    ...

}

now you want to use that class as a parameter in the JPA repository, here's how to do it:

@Query("select c from Customer c where c.name = :#{#customer.name} and c.phoneNumber = :#{#customer.phoneNumber}")
List<Customer> findByNameAndPhone(@Param("customer") Customer customer);