J
john
I have entity A and it has FK to entity B.(B is some lookup table)
when I do this
A a = new A();
B b = new B();
b.setId(1L);
a.setB(b);
and then i call em.persist(a) jpa generates first SQL select statement
to get entity B, and then it generates SQL insert, but when I call
em.merge(b), there is only SQL insert statement ? Why does persist()
needs to check if FK that is set to A exists, and merge() doesn't ?
THANKS IN ADVANCE.
when I do this
A a = new A();
B b = new B();
b.setId(1L);
a.setB(b);
and then i call em.persist(a) jpa generates first SQL select statement
to get entity B, and then it generates SQL insert, but when I call
em.merge(b), there is only SQL insert statement ? Why does persist()
needs to check if FK that is set to A exists, and merge() doesn't ?
THANKS IN ADVANCE.