Does Spring Data JPA have any way to count entites using method name resolving?

后端 未结 12 932
耶瑟儿~
耶瑟儿~ 2020-12-04 08:38

Spring Data JPA supports counting entities using specifications. But does it have any way to count entities using method name resolving? Let\'s say I want a method cou

12条回答
  •  误落风尘
    2020-12-04 09:15

    If anyone wants to get the count with based on multiple conditions than here is a sample custom query

    @Query("select count(sl) from SlUrl sl where sl.user =?1 And sl.creationDate between ?2 And ?3")
        long countUrlsBetweenDates(User user, Date date1, Date date2);
    

提交回复
热议问题