【问题标题】:Why can't the id field be used in where caluse with EclipseLink为什么不能在 EclipseLink 的 where 子句中使用 id 字段
【发布时间】:2012-11-04 17:03:38
【问题描述】:

我正在将应用程序从 Hibernate 移动到 EclipseLink。 我有以下命名查询:

delete from MyObject where id<=:LAST_ID

查询在 Hibernate 中运行良好,但在 EclipseLink 中失败并出现以下错误:

标识变量 'id' 不能与

JPA不允许在where caluse中使用ID字段吗?

任何解决方法将不胜感激。

【问题讨论】:

    标签: java hibernate jpa orm eclipselink


    【解决方案1】:

    对我有用的语法是:

    delete from MyObject mo where mo.id <= :LAST_ID
    

    【讨论】:

      【解决方案2】:

      AFAIK,您始终可以使用 Delete From MyObject Where MyObject &lt;= :LAST_ID 获得相同的效果。无论如何,如果您发布实体定义,我们可能会更有帮助。

      【讨论】:

        猜你喜欢
        • 2018-02-10
        • 1970-01-01
        • 1970-01-01
        • 2013-11-24
        • 1970-01-01
        • 2018-05-31
        • 2013-11-23
        • 1970-01-01
        • 2012-06-11
        相关资源
        最近更新 更多