I've tried your classes and descriptor, and I've found one problem which
is concerned with the initialization of the nested field. To be more
precise, when reading an object from the database, OJB must create the
nested field (child in your case, e.g. setChild/getChild when using
IProduct). In order to do so, it creates an instance (line 293 in
AbstractPersistentField) using newInstance(). This of course won't work
with IChild. I've extracted the newInstance line into a new protected
method createNestedFieldValue which you could override in your
PersistentField subtype like this:

public class MyPersistentFieldImpl extends PersistentFieldIntrospectorImpl
{
    public MyPersistentFieldImpl()
    {
        super();
    }

    public MyPersistentFieldImpl(Class aClass, String aPropertyName)
    {
        super(aClass, aPropertyName);
    }

    protected Object createNestedFieldValue(PersistentField
nestedField) throws InstantiationException, IllegalAccessException
        {
        Class type = nestedField.getType();

        // this of course should be more generic
        if (type == IChild.class)
        {
                return new Child();
        }
        else
        {
                return super.createNestedFieldValue(nestedField);
        }
    }
}

Tom


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to