I somewhat confused by the behaviour of merge(). It seems that if I just new up an entity and set its fields, including the primary key, then I call em.merge(), INSERT is called instead of UPDATE. Is this true?
I am using JPA with JSF. I have a backing bean with a reference to an entity. When I try to edit the entity, on save JSF fills in the fields of the entity from the request and then I call em.merge(), but like I said, that always calls INSERT. The only way I was able to make this work was by scoping the backing bean to the session, such that my entity was alive between calls. That seems like a strange thing to do. The other possibility would be to find the entity and then copy the fields. That also seems like a hack. I guess if merge() is not really UPDATE, is there something else I can call? Thanks, Tim Notice: This email message, together with any attachments, may contain information of BEA Systems, Inc., its subsidiaries and affiliated entities, that may be confidential, proprietary, copyrighted and/or legally privileged, and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient, and have received this message in error, please immediately return this by email and then delete it.
