@Repository
public interface PriceListDurationRepository extends CrudRepository<PriceListDuration, String> {
String mQuery = "SELECT qplt, qplab"
+ " ,(SELECT iuomt1.unitOfMeasure FROM UnitsOfMeasureTransTbl iuomt1) "
+ " FROM PriceListDuration qplab, PriceListDetail qplt "
+ " WHERE qplab.priceListId =qplt.priceListId ";
@Query(value = mQuery + " AND esib.itemNumber = :itemnumber")
Page<PriceListDuration> getByItemNumber(String itemnumber, Pageable pageable);
}
我在getByItemNumber方法中使用分页。但是由于列级的子查询,它返回错误。
如果我删除了
Page<PriceListDuration> getByItemNumber(String itemnumber, Pageable pageable)
与List<PriceListDuration> getByItemNumber(String itemnumber);
一起工作。分页似乎不支持子查询。是否可以使用分页对此方法进行分页?任何帮助将不胜感激
答案 0 :(得分:0)
您可能需要countQuery
,请尝试:
@Query(value = mQuery + " AND esib.itemNumber = :itemnumber",
countQuery = "SELECT count(*) FROM (" + mQuery + " AND esib.itemNumber = :itemnumber" + ")",
nativeQuery = true)
此外,您可能还需要添加Order by
检查样品:
@Query(
value = "SELECT * FROM Users ORDER BY id",
countQuery = "SELECT count(*) FROM Users",
nativeQuery = true)
Page<User> findAllUsersWithPagination(Pageable pageable);