Apache JDO Project - Re: Make dirty of detached objects? Spec Chapter 23

This is Interesting: Free IT Magazines  
Home > Archive > Apache JDO Project > January 2008 > Re: Make dirty of detached objects? Spec Chapter 23





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: Make dirty of detached objects? Spec Chapter 23
Andy Jefferson

2008-01-03, 1:11 pm

> 23.17 Generated methods in least-derived PersistenceCapable class
> public final void jdoMakeDirty (String fieldName);


Adding on support for making fields of detached objects dirty means that th=
is=20
signature will likely have to change :-

1. field names are only known about in the "jdoFieldNames" String[] of each=
=20
class. This doesn't matter with non-detached objects since the field name=20
goes straight across to the StateManager. For detached objects a translatio=
n=20
from field name to field number needs to happen to update the right part of=
=20
jdoDetachedState.

2. Some classes in an inheritance tree can be detachable and some not (same=
=20
issue as jdoIsDetached signature change in JDO-459)



With these in mind, for chapter 23 we can have the following
public void jdoMakeDirty(String fieldName)
{
if (jdoStateManager !=3D null)
jdoStateManager.makeDirty(this, fieldName);
}
for non-detachable root classes, and
public void jdoMakeDirty(String fieldName)
{
if (jdoStateManager !=3D null)
jdoStateManager.makeDirty(this, fieldName);
if (jdoIsDetached())
{
if (fieldName !=3D null && fieldName.indexOf('.') >=3D 0)
{
String className =3D fieldName.substring(0,=20
fieldName.lastIndexOf('.'));
if (className.equals(this.getClass().getName())) {
for (int i =3D 0; i < jdoFieldNames.length; i++) {
if (jdoFieldNames[i].equals(fieldName)) {
if (((BitSet) jdoDetachedState[2]).get(i +=20
jdoInheritedFieldCount)) {
((BitSet) jdoDetachedState[3]).set(i +=20
jdoInheritedFieldCount);
return;
}
throw new JDODetachedFieldAccessException("You have jus=
t=20
attempted to access a field/property that hasn't been detached. Please deta=
ch=20
it first before performing this operation");
}
}
}
super.jdoMakeDirty(fieldName);
}
}
}
for detachable classes



=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