Andrew Clute wrote:

I have looked at all of the examples, I can't seem to make heads or tails of how to handle my situation. I want to map a class that has a reference to an object, that can one of many different objects, that all implement the same interface.

Example

Interface A{

}

class B implements A
{}

class C implements A
{}

class Z
{
    private A myA;
}

So, in this case, how do I map class Z since it's member variable is of Type A, but I want the concrete object, either of Type B or C to be filled in.

Seems like there is no known strategy to do this: "Using Interfaces With OJB" talks about a similar situation, but assumes that there is only one concrete class that can be instantiated for the reference (the factory-method assumes that it will only return one concrete class type).

Seems like I need a combination of the Interface mapping, and the 'ojbConcreteClass' property to have the appropriate concrete class instantiated.

Yes, that should work. You define all common fields in the interface including ojbConcreteClass using getter/setter methods, and you need the PersistentFieldIntrospectorImpl or PersistentFieldAutoProxyImpl for the field access (OJB.properties) as there are no fields only bean methods.
You also should not need factory-class/factory-method now because OJB shouldn't try to instantiate the interface if ojbConcreteClass does not refer to it.


Tom


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



Reply via email to