Hi Andy,

I haven't looked closely at this, but the spec says that this is a sample implementation:

public final boolean jdoIsDetached(){
return jdoStateManager==null?false:
jdoStateManager.isDetached(this);
}

This implies that the state manager is detached along with the instance, so it's only a sample (probably an incorrect one).

I'd say that the implementation you show
public final boolean jdoIsDetached() {return false;}

isn't a correct implementation either.

I'll take a closer look later.

Craig

On Jan 6, 2007, at 12:50 PM, Andy Jefferson wrote:

21.17 states that :-
<spec>
public final boolean jdoIsDetached();
This method checks if the instance is detached. If so, it returns true.
</spec>

If I have
class A {}
class B extends A {}
and A is not detachable yet B is, then what should the jdoIsDetached () method
be in A ?

When "A" is enhanced, it only knows that it is not detachable, and it has no way of detecting if the object is detached since it has no "jdoDetachedState"
field ... so it is given
public final boolean jdoIsDetached() {return false;}
"B" will not be able to override this since it is final


We could add a method jdoGetDetachedState() to return any jdoDetachedState to allow subclasses to give a valid return to whether they are detached and so the jdoIsDetached in superclasses can be correctly enhanced to actually do a
valid check.

If this is the case a jdoIsDetached() method (in the root class) should look
like

public final boolean jdoIsDetached()
{
    if (jdoStateManager == null)
    {
        if (jdoGetDetachedState() == null)
            return false;
        return true;
    }
    return false;
}

and the root (non detachable) "A" will have

protected Object jdoGetDetachedState()
{
    return null;
}

and B can have

protected Object jdoGetDetachedState()
{
    return jdoDetachedState;
}




Opinions ? Anything I've overlooked?

--
Andy

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

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to