Hibernate / JPA many to many relationship through a join table and a composite key, Unique Constraint issue

南楼画角 提交于 2019-12-04 08:18:00

It actually seems quite logical that Hibernate puts a unique constraint on the type and value column.

You say in the @ManyToMany mapping that in the jointable the joincolumns are the type and value column. So basically you say that hibernate should determine which element is coupled to the ElementCategory by the value and type property. therefore the combination ofthose 2 properties should be unique. Otherwise hibernate would not know which Element belong to what ElementType

If you want that multiple Element entities can be coupled to multiple ElementType Entities and the combination of type and value is not always unique, then you can't use those properties as joincolumns

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!