users@glassfish.java.net

Re: JPA/Toplink? question related to _at_Transient fields

From: <glassfish_at_javadesktop.org>
Date: Thu, 15 May 2008 10:22:04 PDT

> First, merge is different from persist. Persist does
> take the object passed in and make it managed, where
> as merge must return a managed instance. The spec
> explicitely states that merge will make a copy of the
> detached object to use as the managed object -
> keeping the object passed in detached.

Right; got all that.

> So this
> precludes providers from simply determining if the
> object is new and then calling persist on it

OK; I see.

> I can't recall what the spec states about transient
> data. But from a practical point, a provider could
> not reliably copy/merge transient data from detached
> objects into managed objects.

Right, but the data I'm talking about may be @Transient, but is [i]not[/i] transient. In case that makes any difference.

(Bearing in mind, of course, that I freely recognize this is all moot--I just do an entityManager.contains(myObject) test first to see whether I should persist() or merge()--I'm just curious about why various decisions were made.)

Best,
Laird
[Message sent by forum member 'ljnelson' (ljnelson)]

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