java - JPA @ManyToOne update association link in both sides -
class a
@manytoone private b b;
class b
@onetomany (mappedby ="b") private list<a> lista = new arraylist<a>(); private void adda(a a) { lista.add(a); }
so owning side, if a.setb(new b()) merge work , association kept.
if b.adda(new a()) merge b, link between , b not updated right ? should b.add(new a()) update link between , b ?
thank much
i don't understand question well, think should add in method adda
private void adda(a a) { lista.add(a); a.setb(this); }
Comments
Post a Comment