【问题标题】:How to get 2nd Last Record using Jpa query [duplicate]如何使用 Jpa 查询获取第二条最后一条记录 [重复]
【发布时间】:2014-10-23 11:39:45
【问题描述】:

这是我的 oracle 查询,它给出了正确的结果。 SELECT * FROM(SELECT a.*, row_number() OVER(ORDER BY ELB_ID DESC) rn FROM BILL a) where rn=2 AND ACCOUNT_ID=486;

【问题讨论】:

  • 你试过什么?你用过 setMaxResults, setFirstResult 吗?

标签: oracle hibernate jpa


【解决方案1】:

我试图通过将 ELB_ID 的顺序更改为 ASC 并使用 setFirstResult 和 setMaxResults 来恢复您的查询:

TypedQuery<Bill> q = entityManager.createQuery("select a from Bill a where a.accountId=:accountId order by a.elbId");
q.setParameter("accountId", 486);
q.setFirstResult(2);
q.setMaxResults(1);

【讨论】:

    猜你喜欢
    • 2017-05-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-08
    • 2019-12-28
    • 2010-11-25
    • 2014-07-26
    相关资源
    最近更新 更多