db-jdo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andy Jefferson <a...@jpox.org>
Subject JDO2 Spec : jdoIsDetached()
Date Sat, 06 Jan 2007 20:50:49 GMT
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

Mime
View raw message