(lazy) m:n relation + EventListener = AssertionFailure: collection [n-side] was not processed by flush()
链接:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2763
hibernate的event系统和它原有的机制有点区别.....如果想通过preUpdate or PostUpdate去修改原先的值,还是不要了,因为这样lazy就不能用了.....
这哥们总结的好:
My conclusion was, that you have not to change the state of the current object in the current session within events.
But if you want only use changed attributes - use the findDirty() (ore something called like this)(实际上是getOldState()) to touch only changed (and loaded) attributes.
链接:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2763
hibernate的event系统和它原有的机制有点区别.....如果想通过preUpdate or PostUpdate去修改原先的值,还是不要了,因为这样lazy就不能用了.....
这哥们总结的好:
My conclusion was, that you have not to change the state of the current object in the current session within events.
But if you want only use changed attributes - use the findDirty() (ore something called like this)(实际上是getOldState()) to touch only changed (and loaded) attributes.
本文探讨了Hibernate中懒加载(m:nrelation+EventListener)机制与AssertionFailure错误的关系,特别是当尝试在preUpdate或postUpdate事件中修改对象状态时的问题。作者建议使用findDirty或getOldState方法来仅触碰已更改的属性。
1609

被折叠的 条评论
为什么被折叠?



