How to force EclipseLink's @PrivateOwned to perform delete before insert

懵懂的女人 提交于 2020-08-02 12:29:25

问题


I have an entity which has @OneToMany private ownership of a collection of another entities.

That other entity has some unique constraints over different set of columns.

The problem arises when I want to update the main entity (together with changed child entities). EclipseLink does insert before delete, so sometimes, an insertion violates the constraint and throws an exception.

Is there a way to force the deletion of child entities before inserting their updated counterparts?


回答1:


I know, I'm a bit late, but anyway:

 UnitOfWork uow = JpaHelper.getEntityManager(em).getUnitOfWork();
 uow.setShouldPerformDeletesFirst(true);
 uow.setShouldOrderUpdates(true);

But sometimes also updateBeforeInsert would be needed, no idea to force that.



来源:https://stackoverflow.com/questions/19808744/how-to-force-eclipselinks-privateowned-to-perform-delete-before-insert

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!