persistence@glassfish.java.net

Why does EntityManager.merge() return a reference and persist() doesn't?

From: Jon Miller <jemiller_at_uchicago.edu>
Date: Fri, 12 Jan 2007 18:49:30 -0600

I'm starting to get confused here. Why does merge() return a reference that
is in the persistence context? Why doesn't it just use the reference that
you pass in? I don't understand why the behavior is different for merge()
than for persist().

I've been using merge() for both adding and updating objects. I'm thinking
that maybe I should be using persist() for adding new objects and only use
merge() for existing objects.

Jon