Hello,
I need do disable an unique constraints for the time of an update.
Consider the following example:
Code:
@Entity
@Table(uniqueConstraints = @UniqueConstraint(columnNames = { "personID", "fieldID" }))
public class SomeMappingTable {
private Integer personID;
private Integer fieldID;
// ...
}
Ok, assume I have to entries in it
Code:
fieldID: 1 ("Mathematics")
fieldID: 2 ("English")
The user has 2 combos: in the first Mathematics is selected, in the second one English.
Now, if the users switches the values (Mathematics -> English and English -> Mathematics) the unique constraint is violated because after the first update the table would contain English twice.
So, the only way how to solve the problem is to disable the unique constraint for the time of the update. Maybe somebody knows another solution.
Thanks a lot,
Kasperl