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: 2.1 Spec: detached-dirty parameters to makePersistent() when DetachAllOnCommit=true
Date Thu, 09 Aug 2007 02:29:21 GMT
So if we introduce a flag that uses the same instance on attach, we  
might want to have the flag called CopyOnMakePersistent and have true  
be the current specified behavior and false be the new behavior we've  
been discussing.

The defaults for these kinds of options have never been specified  
(even Optimistic).

Craig

On Aug 7, 2007, at 12:11 PM, Andy Jefferson wrote:

>> With this restriction in place, however, would I be able to do the
>> following?
>
>> // fetch a detched object
>> Query q = pm.newQuery(Foo.class);
>> q.setUnique(true);
>> Foo foo = (Foo) q.execute();
>
> "detachAllOnCommit" will transition instances to detached *at  
> commit*. You
> have no commit here (using nontransactionalRead ?). If you have  
> tx.begin(),
> tx.commit() around it then its definitely fine. Nothing in the spec
> definition of "detachAllOnCommit" implies (to me) that queries run  
> with
> non-tx read will do the detach.
>
>> // make it dirty:
>> foo.setBar("bar");
>
> "foo" : detached-clean -> detached-dirty
>
>> // attach
>> pm.currentTransaction().begin();
>> pm.makePersistent(foo);
>
> "foo" : detached-dirty -> persistent-clean
>
>> pm.currentTransaction().commit();
>
> "foo" : persistent-clean -> detached-clean
>
>> // dirty it once more
>> foo.addBaz("baz");
>
> "foo" : detached-clean -> detached-dirty
>
>> // and attach it a second time
>
> "foo" : detached-dirty -> persistence-clean
>
>> - wouldn't this cause the  JDOUserException you mention above?
>
> No. If referring to the same PM, the object would have been removed  
> from L1
> cache at detach. The exception I was referring to was if you did a  
> separate
> PM.detachCopy() or detached it from a different PM and *then* tried  
> to attach
> to the same PM as one that already had it.
>
>
>
>
> -- 
> Andy  (Java Persistent Objects - http://www.jpox.org)

Craig Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!


Mime
View raw message