Google News
logo
JPA - Interview Questions
In JPA EntityManager why use persist() over merge() ?
Persist :
* Persist takes an entity instance and adds it to the context making that instance managed.
* Insert a new register to the database.

Merge :
* Merge creates a new instance of your entity, copies the state from the supplied entity and then makes the new copy managed.
* Find an attached object with the same id and update it.
Advertisement