Java 8 Spring Data JPA Parameter binding

前端 未结 3 680
轻奢々
轻奢々 2021-01-11 09:35

In my @Repository interface I created custom find method with JPQL @Query that contains parameter (addressType).

from Address a where a.addressType = :addressT

3条回答
  •  醉梦人生
    2021-01-11 10:02

    In Java 8, you can use reflection to access names of parameters of methods. This makes the @Param annotation unnecessary, since Spring can deduce the name of the JPQL parameter from the name of the method parameter.

    But you need to use the -parameters flag with the compiler to have that information available.

    See http://docs.oracle.com/javase/tutorial/reflect/member/methodparameterreflection.html.

提交回复
热议问题