Hi,
I have created a custom identifier generator. On my id property, of type long, I added a @GenericGenerator annotation and passed the name to the @GeneratedValue annotation.
The entity has a uniqueConstraint on 3 columns, one of which is an id of another entity. Something like:
@Table(name = "entity", uniqueConstraints = {@UniqueConstraint(columnNames = {"resource_id", "source", "destination"})})
In a test I created two entities that violate the uniqueness (they have the same resource entity and source and destination values). Saving the entities passes, but trying to find all entities of the table fails with a unique constraint violation.
If I remove the custom generator (so using the native one), the test passed. Also, trying to flush the session in the generator makes no difference. I looked at the generated schema and the constraint is there. So my guess is that the 2nd entity is not really saved to the db.
How can I solve this? Regards, Ittay
|