【问题标题】:Getting the first record got by orderBy clause using queryDSL使用 queryDSL 获取 orderBy 子句获取的第一条记录
【发布时间】:2018-08-21 17:14:56
【问题描述】:

我需要编写一个 QueryDSL 来获取表中的最新记录。为此,我根据 timeCreated 降序排序,并且我使用 singleResult 来获取第一条记录。

Object obj;
Object result = (Object) query.from(table)
    .where(CLAUSE)
    .orderBy(timeCreated.desc())
    .singleResult(obj);

如果上面的(singleResult)总是会获取排序列表中的第一条记录(最新记录),我需要澄清一下

【问题讨论】:

    标签: java jpql querydsl


    【解决方案1】:

    querydsl 3 docssingleResult

    对于多个结果,仅返回第一个结果

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-03-09
      • 2014-11-08
      • 1970-01-01
      • 1970-01-01
      • 2015-03-15
      • 1970-01-01
      • 2013-12-20
      • 1970-01-01
      相关资源
      最近更新 更多