在@Query中排序选择不起作用

时间:2017-02-23 12:15:04

标签: java hibernate jpa spring-boot

我在我的JPA存储库中有这个查询 - 除了“order by”部分之外它还可以工作。我这样做错了吗?它在hql中有什么不同吗?

@Query(value = "select wm.WagerIdentification, wm.BoardNumber, wm.MarkSequenceNumber, wm.MarkNumber," +
        " pt.CouponTypeIdentification, pt.WagerBoardQuickPickMarksBoard " +
        "from WagerBoard wb " +
        "inner join wb.listOfWagerMarks wm  " +
        "inner join wb.poolgameTransaction pt  " +
        "where wb.WagerIdentification = wm.WagerIdentification and wb.BoardNumber = wm.BoardNumber and wb.GameIdentification = wm.GameIdentification and wm.meta_IsCurrent = 1 " +
        "and wb.TransactionIdentification = pt.TransactionIdentification and pt.meta_IsCurrent = 1 " +
        "and wb.meta_IsCurrent = 1 order by wm.WagerIdentification asc, wm.BoardNumber asc, wm.MarkNumber asc")

1 个答案:

答案 0 :(得分:2)

您可以添加Sort类型的方法参数,而不是在Spring Data JPA reference

中添加排序类型的方法参数。