users@glassfish.java.net

Re: JPA - why persist and merge, why not a sigle save

From: <glassfish_at_javadesktop.org>
Date: Tue, 24 Jul 2007 20:49:56 PDT

Simon, thanks for the documents.

Under section "3.7. Automatic state detection" it says "[i]The merge operation is clever enough to automatically detect whether the merging of the detached instance has to result in an insert or update. In other words, you don't have to worry about passing a new instance (and not a detached instance) to merge(), the entity manager will figure this out for you:[/i]"

It means that you can use the merge operation for both ways of working (as defined in your reply) . So why should specification bother itself to introduce a second operation (persist)?

The only reason I can think of as of now, is the performance concern. IMHO, specifications should be as simple as possible and leave these kind of fine tuning to implementations.
[Message sent by forum member 'mohammadwrk' (mohammadwrk)]

http://forums.java.net/jive/thread.jspa?messageID=228084