Spring data JPA query with parameter properties

后端 未结 9 1180
既然无缘
既然无缘 2020-11-29 00:20

What is the simplest way of declaring a Spring data JPA query that uses properties of an input parameter as query parameters?

For example, suppose I have an entity c

9条回答
  •  孤独总比滥情好
    2020-11-29 01:09

    This link will help you: Spring Data JPA M1 with SpEL expressions supported. The similar example would be:

    @Query("select u from User u where u.firstname = :#{#customer.firstname}")
    List findUsersByCustomersFirstname(@Param("customer") Customer customer);
    

    https://spring.io/blog/2014/07/15/spel-support-in-spring-data-jpa-query-definitions

提交回复
热议问题