Kal*_*kar 2 spring spring-data-jpa
我试图用Spring数据JPA实现以下查询,方法名称解析.
select count(*) from example ex where ex.id = id and ex.status in (1, 2);
Run Code Online (Sandbox Code Playgroud)
我知道crud repo中有一个方法可以计算 - countByIdAndStatus(params)但我不知道如何将"in"子句与此方法结合起来.
谢谢!
这是你如何做到的:
long countByIdAndStatusIn(Integer id, List<Type> params);
Run Code Online (Sandbox Code Playgroud)
用@Query:
@Query("select count(*) from Example ex where ex.id = ?1 and ex.status in (?2)")
long countByIdAndStatus(Integer id, List<Type> params);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2220 次 |
| 最近记录: |