end*_*ser 5 spring jpql spring-el spring-data-jpa
在查看Spring Data JPA 存储库的查询创建时,我想知道如何重用参数。例如,如果我想做类似的事情,我将如何命名该方法:
@Query("select c from #{#entityName} c where c.lower <= ?1 and c.upper >= ?1")
E findByConversionFor(Double amount);
Run Code Online (Sandbox Code Playgroud)
该查询是否可以转换为 SpEL 方法名称(由查询构建器使用)?
要求将相同的值传递两次似乎是一种拼凑:
E findByLowerLessThanOrEqualAndUpperGreaterThanOrEqual(Double a, Double b); // where a==b
Run Code Online (Sandbox Code Playgroud)
只需标记您的参数@Param("amount"),然后就可以按名称使用它:
@Query("select c from #{#entityName} c where c.lower <= :amount and c.upper >= :amount")
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2724 次 |
| 最近记录: |