问题描述
当我尝试保存类型为 Member
invitingMember.save(flush:true)
以下例外
在事务之前,我将一个对象添加到 invitingMember
的集合属性中。我的猜测是,上面的行引发了异常,因为只是在这一点上,添加到集合中的对象才会持久。
当我尝试保存类型为 Member
invitingMember.save(flush:true)
以下例外
在事务之前,我将一个对象添加到 invitingMember
的集合属性中。我的猜测是,上面的行引发了异常,因为只是在这一点上,添加到集合中的对象才会持久。
潜在的问题可能是Hibernate没有级联保存。所以当你刷新 Member
时,Hibernate发现集合仍然很脏(这可能不是你想要的)。因此,要么手动刷新收藏夹,要么。
I have an integration test in my Grails application that fails when I try to save an entity of type Member
invitingMember.save(flush: true)
This raises the following exception
Earlier in the transaction I add an object to a collection property of invitingMember
. My guess is that the exception is thrown at the line above, because it's only at this point that the object added to the collection is persisted.
The underlying problem is probably that Hibernate doesn't cascade the save. So when you flush the Member
, Hibernate notices that the collection is still dirty (which is probably not what you want). So either flush the collection manually or tell Hibernate to cascade all the updates.
这篇关于Hibernate / GORM:集合未被flush()处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!