db-jdo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Craig L Russell <Craig.Russ...@Sun.COM>
Subject Re: RETRY: Transient instance referencing a detached instance? (was: Question about attachCopy, transient & detached instances)
Date Sun, 16 Oct 2005 19:26:17 GMT
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" <wes@tralfamadore.com> wrote in message
> news:<mailman.5533.1128524276.10966.jdo-general@jdo-experts.org>...
>
>> 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
>
>
>


Mime
View raw message