【问题标题】:"missing SET keyword" on hibernateTemplate bulkUpdatehibernateTemplate bulkUpdate 上的“缺少 SET 关键字”
【发布时间】:2011-03-20 09:15:42
【问题描述】:

我的命名查询:

@NamedQuery(name = "myUpdate", query = "update User set country = 'EN' where user.id = ?")

在服务层:

Query query = sessionFactory.getCurrentSession.getNamedQuery("myUpdate");
getHibernateTemplate.bulkUpdate(query.getQueryString(), id);

我收到一个错误:

休眠:更新用户,设置 country=EN 其中 id = 2343 ORA-00971: 缺少 SET 关键字

现在有人可以解决这个问题吗?

【问题讨论】:

标签: java hibernate spring


【解决方案1】:

您是否在 hibernate.cfg.xml 文件中指定了 oracle 方言?您提供的命名查询由 Hibernate 转换为特定于 DB 的查询。如果方言错误,翻译产生的 SQL 对于目标数据库可能是错误的。

看到update User, set中的逗号?

【讨论】:

  • 1.我将休眠方言设置为 org.hibernate.dialect.OracleDialect。我看到了一个逗号。我不知道去哪里。
  • 你怎么看,那个逗号在哪里?
  • 我在 Hibernate 4 中遇到了同样的问题,我确实指定了 <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>。在 persistence.xml 中。
【解决方案2】:

Hibernate 似乎在批量更新和隐式/显式连接方面存在限制。 我找到了一个解决方案 http://www.techques.com/question/1-5368522/Why-this-hibernate-template-bulkUpdate-doesn't-work

【讨论】:

    猜你喜欢
    • 2019-12-11
    • 2014-11-09
    • 1970-01-01
    • 2012-03-05
    • 2018-10-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多