Dhananjay
Dhananjay

Reputation: 414

Hibernate- One to Many Mapping - save relation mapping but not the nested Entity

I have Entity A(Role) having OneToMany relationship to Entity B(Functions), when I am trying to save A, when I run it first time everything works well, next time when I want to add new role with some of functions, I get error as UNIQUE constraint as there are already records in Functions entity.

How can I save just mapping between A & B if records are already available in B.

Upvotes: 0

Views: 72

Answers (1)

v.ladynev
v.ladynev

Reputation: 19976

Please, use a @ManyToMany mapping.

Upvotes: 1

Related Questions