EntityManager.merge()
can insert new objects and update existing ones.
Why would one want to use persist()
(which can only create new objec
Going through the answers there are some details missing regarding `Cascade' and id generation. See question
Also, it is worth mentioning that you can have separate Cascade
annotations for merging and persisting: Cascade.MERGE
and Cascade.PERSIST
which will be treated according to the used method.
The spec is your friend ;)