HIbernate query parameter binding -


i perform native sql query via hibernate:

dbs.createsqlquery("update users set :balancetype = :newbalance ukey = :ukey")     .setstring("balancetype", type.tostring())     .setbigdecimal("newbalance", newbalance)     .setlong("ukey", ukey).executeupdate(); 

this fails because of :balancetype binding.

i exception:

org.hibernate.exception.sqlgrammarexception: not execute native bulk manipulation query org.hibernate.exception.sqlgrammarexception: 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 not execute native bulk manipulation query update users set :balancetype = :newbalance ukey = :ukey java.sql.sqlexception: ora-01747: invalid user.table.column, table.column, or column specification 

if use string.format embed paraneters in string works fine!

any idea what's wrong syntax??

thanks!

balancetype not parameter, cannot bind it, need concatenate column name using string concatenation.

dbs.createsqlquery("update users set " + type.tostring() + " = :newbalance ukey = :ukey")     .setbigdecimal("newbalance", newbalance)     .setlong("ukey", ukey).executeupdate(); 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -