01-03-08 06: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 e
ach=
=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)
[ Post a follow-up to this message ]
|