Clute, Andrew wrote:
So, let's say that the classes that implement this interface have nothing in common, than the fact that they implement the same interface (existing classes that are modified to implement this interface to give some commonality to them), so there are no common properties between them.
In this case, would that mean the only get/set I would need to define on the interface is for ojbConcreteClass?
I am so not sure how the the reference would work...the class that has the reference has a column for the FK to that referenced object, but should it also contain the objConcreteClass field to the class-type of the referenced object? This is were my confusion is.
No, only the referenced object requires the ojbConcreteClass field (or bean property in your case). However, you'll need to have common primary key for all classes that derive from the interface with getters/setters in the interface, because this is what the FK references.
You're right in one thing though: this will work flawlessly only if all subclasses of the interface are mapped to the very same table, but otherwise the ojbConcreteClass stuff won't work anyway AFAIK.
To give some more concrete to the example, here is what I have...I have two different objects that already exist: Course and CatalogItem. Now at this point we need to start accepting payment for them, so I have created an Order and OrderItem, and I want the OrderItem to be able to contain either one of the objects. So I created a Sellable interface, and Course and CatalogItem now implement them. So, I now need to figure out how to map OrderItem so that when it is restored, the right object (Course or CatalogItem) is created.
This will work if both Course and CatalogItem map to the same table. If you require them to be in different tables, then you'll probably have to do the loading manually. This means that you have the basic parts (primary key, ojbConcreteClass) in the same table, and load the other fields/references/collections on your own in the constructor of the concrete subclass. This is a bit more involved though.
Tom
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
