我正在使用 Spring Data JPA,当我使用 @Query
来定义一个 没有 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);
}
但是如果我添加第二个参数 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);
}
原文由 Awakening 发布,翻译遵循 CC BY-SA 4.0 许可协议
在 Spring 论坛上提出了 类似的问题,其中指出要应用分页,必须派生第二个子查询。因为子查询引用相同的字段,所以您需要确保您的查询对它引用的实体/表使用别名。这意味着你写的地方:
你应该改为: