- , , JPA, , . , . - , mappedBy. , , A, B.
, A B,
A a = em.find(A.class, aId);
B b = em.find(B.class, bId);
a.setB(b);
JPA will save the association (i.e., store identifier B in the join column of table A).
But if you do
A a = em.find(A.class, aId);
B b = em.find(B.class, bId);
b.setA(a);
nothing will be changed in the database because you changed the back side and forgot to change your side.
source
share