开发者

Setting unique constraint on all referenced collection members in hibernate

开发者 https://www.devze.com 2023-03-09 04:04 出处:网络
imagine you have a Hibernate/JPA entity class Text which may be annotated with multiple members of class Tag - how would you ensure that Text ent开发者_JAVA百科ity exist only once for a set an arbitra

imagine you have a Hibernate/JPA entity class Text which may be annotated with multiple members of class Tag - how would you ensure that Text ent开发者_JAVA百科ity exist only once for a set an arbitrary combination of Tags?

Thank you for help.


I would make a hash of the keys of the Tags and put a unique key on that. There isn't really any built in way to ensure a Bag's contents are unique.

0

精彩评论

暂无评论...
验证码 换一张
取 消