|
Hibernate 4.2.8 and 4.3.6
We have a 1:1 relationship that we're trying to setup between two entities. Define the parent as: @OneToOne( orphanRemoval = true ) @Cascade( CascadeType.ALL ) private E2 e2;
and the child as: @ManyToOne( optional = false ) private E1 e1;
(also tried @OneToOne on the child mapping).
There's a unique constraint on the child table on (Child.e1). When setting a new Child on the Parent (in this example, e1.setE2( new E2() ); ); Hibernate issues the insert for the new E2 instance before the delete takes place, so runs in to the unique constraint. We confirmed that if we remove the table constraint, then at the end everything is as expected, since the deletion occurs. However, we cannot remove the unique constraint on that child table in most of these mapping cases.
Is there any reason why the delete couldnt be processed prior to the insert?
|