我想通过休眠执行本机 SQL 查询:
dbs.createSQLQuery("UPDATE USERS SET :balanceType = :newBalance WHERE UKEY = :ukey")
.setString("balanceType", type.toString())
.setBigDecimal("newBalance", newBalance)
.setLong("ukey", uKey).executeUpdate();
由于 :balanceType 绑定,此操作失败。
我得到了例外:
org.hibernate.exception.SQLGrammarException: could not execute native bulk manipulation query
org.hibernate.exception.SQLGrammarException: could not execute native bulk manipulation query
java.sql.SQLException: ORA-01747: invalid user.table.column, table.column, or column specification
org.hibernate.exception.NestableDelegate@431d9f05
could not execute native bulk manipulation query
UPDATE USERS SET :balanceType = :newBalance WHERE UKEY = :ukey
java.sql.SQLException: ORA-01747: invalid user.table.column, table.column, or column specification
如果我使用 String.format 在字符串中嵌入参数,那么它工作正常!
知道我的语法有什么问题吗?
谢谢!