Javadogs,

I've reviewed this material and agree with the general conclusion, that we can add the ability to include detached objects in the closure of instances for both makePersistent and attachCopy.

The spec as of today requires treating these three types of objects in the closure differently:

persistent instances

attachCopy throws an exception; makePersistent ignores them

transient instances

attachCopy copies them and creates persistent-new instances; makePersistent makes them persistent-new

detached instances

attachCopy copies them; makePersistent throws an exception

Here's the change as I would propose it:

persistent instances

attachCopy ignores them; makePersistent ignores them

transient instances

attachCopy copies them and creates persistent-new instances; makePersistent makes them persistent-new

detached instances

attachCopy copies them; makePersistent copies them

If we make this change, the behavior of makePersistent and attachCopy are more similar than today. The differences are in the treatment of transient instances and whether or not the root objects are returned. If we like, we can have makePersistent also return the root objects by making a source-compatible change to the signatures of makePersistent.

Craig

On Oct 5, 2005, at 11:59 AM, Matthew T. Adams wrote:

"Wes Biggs" <[EMAIL PROTECTED]> wrote in message
news:<[EMAIL PROTECTED]>...

Would it be cleaner to not allow transient instances to be included in
attachCopy() graphs at all?  Sounds that way to me.


No, I'd like to continue to allow transient instances to be included in attachCopy graphs. I'd like to **add** the ability for detached objects to
be included in makePersistent graphs.

This use case fell out very naturally for me while working on a website that uses detached objects. I ended up with a transient User object referencing
a detached Country object, and, of course, when I called
pm.makePersistent(user), I got an JDOUserException as I should have, per the
spec as it stands right now.

--matthew




Reply via email to