Hi, Beno�t
Thanks for your explaination.
For the entityManager.merge(), I still feel confused with the result of mergering the existing entity :
1) From MZ's guide:
For a given entity A, the merge method behaves as follows:
If A is a DETACHED entity, its state is COPIED into existing managed instance A' of the same entity identity, or a new managed copy of A is created.
If A is a NEW entity, a new MANAGED entity A' is created and the state of A is COPIED into A'.
If A is an existing MANAGED entity, it is IGNORED. However, the merge operation still cascades as defined below.
If A is a REMOVED entity, an IllegalArgumentException is thrown.
The merge operation recurses on all relation fields of A whose cascades include CascadeType.MERGE.
2) From O'Reilly book 'Enterprise
Java Bean 3.0'
If the entity manager isn't already managing a Cabin instance with the same ID, a full copy of the cabin parameter is made and
returned from the merge( ) method. This copy is managed by the entity manager, and any additional setter methods called on
this copy will be synchronized with the database when the EntityManager decides to flush. The cabin parameter remains
detached and unmanaged.
If the entity manager is already managing a Cabin instance with the same primary key, then the contents of the cabin
parameter are copied into this managed object instance. The merge( ) operation will return this managed instance. The cabin
parameter remains detached and unmanaged.
I would more agree with the O'Reilly
EJB 3.0 and your explaination - merge the existing managed entity will basically update the state of that entity.
I don't quite understand the explaination on MZ's
IGNORED
.
Can anyone share with your thinking?
thanks
Helen