【问题标题】:JPQL query errorJPQL 查询错误
【发布时间】:2014-06-18 09:49:43
【问题描述】:

考虑以下正确的查询

select _.* from _misc._lang__ _ where _.id > 10 order by _.id asc limit 1 offset 0

现在我尝试像这样进行 JPQL 查询

select l from _misc._lang__ l where l.id > :arg order by l.id asc limit 1 offset 0

还有错误(EclipseLink)

The ORDER BY clause has 'l.id ASC ' and 'limit ' that are not separated by a comma.

似乎 eclipse 链接将limit 作为列名而不是关键字,现在我该如何修复它?
谢谢!

【问题讨论】:

  • 我建议你学习 JPQL 的语法:它使用类名而不是表名,它不使用 .*,它没有限制和偏移子句。简而言之,它是一种与 SQL 不同的语言,你必须学习它。
  • @JBNizet 对不起,错字:D

标签: postgresql jpa jpql


【解决方案1】:

“限制”未重新调整。您可以像这样使用yourQuery.setMaxresults 方法:

result=em.createQuery("select l.* from _misc._lang__ l where l.id > :arg order by l.id asc").setParameter("arg", yourArg).setMaxResults(2).getResultList()

【讨论】:

    猜你喜欢
    • 2015-08-18
    • 1970-01-01
    • 2019-10-27
    • 2019-12-17
    • 2017-03-10
    • 2013-11-13
    • 2018-02-23
    • 2011-11-21
    • 2011-07-30
    相关资源
    最近更新 更多