Apache JDO Project - Re: 2.1 Spec: detached-dirty parameters to makePersistent() when DetachAllOnCommit=tru

This is Interesting: Free IT Magazines  
Home > Archive > Apache JDO Project > August 2007 > Re: 2.1 Spec: detached-dirty parameters to makePersistent() when DetachAllOnCommit=tru





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Re: 2.1 Spec: detached-dirty parameters to makePersistent() when DetachAllOnCommit=tru
Andy Jefferson

2007-08-07, 7:11 pm

=46rom discussion on JPOX forum about the same issue :-

Now I can detach 2 or more copies of the very same persistent object.=20
Consequently if I start a PM and decide I'm attaching them both, you would=
=20
then expect the JDO implementation to play around with 2 persistent objects=
=20
with the same underlying identity?

Or to give an example :-
* Object "x" is persistent with id "xId".
* I detach "xd1" and "xd2", both with the same identity "xId".
* I then start a PM and attach "xd1" and this migrates into P_CLEAN, and go=
es=20
into the L1 cache as such referenced by the id "xId".
* I then attach "xd2" and this migrates to P_CLEAN, and ... oh we can't cac=
he=20
that one since the identity already exists in the L1 cache but referring to=
a=20
different object, breaking object uniqueness for an identity.



So if you had a flag "javax.jdo.option.AttachOnPersist" that effectively=20
changed the functionality of PM.makePersistent() to not return a COPY but t=
o=20
migrate the state of the passed object to persistent, then you hit this=20
problem above.

You could allow something of this form by imposing a restriction that if an=
=20
object needs attaching, and that "AttachOnPersist" flag is set, and the PM=
=20
already has a persistent object with that id then throw a JDOUserException.=
=20
Clearly the primary use-case is where the user detaches a single object, an=
d=20
then wants to attach the same thing, so they typically never hit the=20
duplicate detached object issue.


=2D-=20
Andy =A0(Java Persistent Objects - http://www.jpox.org)

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com