jpa persist , merge ?

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top