You got the set the key value for the newly created object. For example:
Then Hibernate will be able to identify that this object is already existing object and it just has to update the object. Else if there's no key or the key doesn't exist in DB, merge() will save it as a new object.
subject: Generated ID in JPA + Hibernate - updated ID in the original object?