Unique Constraints and Delete and Insert Order - Constraint Violation [message #1053635] |
Tue, 07 May 2013 02:23 |
Eduardo Frazão Messages: 123 Registered: January 2012 |
Senior Member |
|
|
Hi Folks..
I have this scenario:
class A {
@Id
Integer id;
@OneToMany(cascade=ALL)
Set<B> bList;
}
@UniqueConstraint(a, c)
class B {
@Id
integer id;
@ManyToOne
A a;
@ManyToOne
C c;
... Some other stuff
}
private class C {
@Id
Integer id;
... Some other stuff
}
Adding new B objects on the A list, everything works.
But, if I remove an B Object from the A list, and adds another, with a C relation equals to the removed object, an UniqueConstraint exception occours because eclipselink try to first insert or update the actual objects, and after, delete.
I read on the documentation that this is the normal behavior, and for now, i'm configuring the UnitOfWork of this transaction to perform deletes before, using the setShouldPerformDeleteFirst property. It works.
But theres no other way that I can configure the UniqueConstraint, that Eclipselink will understand that it needs to perform's delete first? Like configuring some kind of ID relation between the two entities (A and C) over the B mapping?
Thanks
|
|
|
|
Powered by
FUDForum. Page generated in 0.01349 seconds