I’m having an Entity that contains a Set like the following:
@ElementCollection
Set<String> branches;
Now what Hibernate does, is creating a table project_branches (project_id | branches) and adding a unique constraint on branches. Is there any way to tell hibernate that the unique constraint should involve both, project_id and branches?
I could not find an answer to this question, though I think I’m not the first with this problem… Thanks
This is dependent on the columns involved in the mapping.
There in one other configuration. Please consider adding an
UniqueConstraintannotation at entity level e.g. below:EDIT: Try using
@CollectionTableannotation.