我正在使用Spring Data JPA,当我@Query用来定义查询WITHOUT时 Pageable,它可以工作:
public interface UrnMappingRepository extends JpaRepository<UrnMapping, Long> {
@Query(value = "select * from internal_uddi where urn like %?1% or contact like %?1%",
nativeQuery = true)
List<UrnMapping> fullTextSearch(String text);
}
Run Code Online (Sandbox Code Playgroud)
但是如果我添加第二个参数Pageable,那么@Query它将不起作用,Spring将解析方法的名称,然后抛出异常 No property full found.这是一个错误吗?
public interface UrnMappingRepository extends JpaRepository<UrnMapping, Long> {
@Query(value = "select * from internal_uddi where urn like %?1% or contact like %?1%",
nativeQuery = true)
Page<UrnMapping> fullTextSearch(String text, Pageable pageable);
}
Run Code Online (Sandbox Code Playgroud) 如何Pageable仅使用排序信息将对象传递给 Spring JPA Repository?我想要这样的东西:
Pageable pageable = PageRequest.of(null, null, Sort());
Run Code Online (Sandbox Code Playgroud)
我知道它需要intaspage和size但是如果我们不能以某种方式使用这些值并给出一个未分页的结果
Sort.by(Sort.Direction.ASC, "age")
我们可以对页面和大小使用像1000,这样的大数字,1000但我不想对这些值进行硬编码。
我也不打算为Pageable.
请让我知道如何实现这一目标。
提前致谢。