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

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -