entitymanager merge example
The persist operation must be used only for new entities.
From JPA perspective, an entity is new when it has never been
associated with a database row,
meaning that there is no table record in the database to match
the entity in question.
For Merge read the associated link