我有 hibernate 逆向工程生成的带有复合键的类。我想使用复合键更新我的表列(即非复合键)。我尝试过,但没有出现异常,无法执行我的查询。
Query query= session.createQuery(update textvalues d set d.mytext=:newtext"+"where d.id.firstId=:firstId and d.id.secondid=:secondId ");
这里,mytext是textvalues表的一列。 firstId 、 secondaryId 是复合键。如果我单独更新 id 值,它会起作用,但不适用于 mytext 列,但执行良好。我不擅长调试,但是当我这样做时,我得到了 org.hibernate.NonUniqueResultException
control not come after or execute after this line **session.createQuery()**
最佳答案
这里只是在黑暗中刺一下......
update textvalues d
set d.mytext = :newtext
where d.firstid = :firstId
and d.secondid = :secondId
关于java - hibernate更新查询复合键示例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19788184/