开发者

Setting unique constraint on all referenced collection members in hibernate

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜