Thomas Dudziak wrote:
Maksimenko Alexander wrote:
<!-- Interface ABC -->
<class-descriptor class="ABC"><extent-class class-ref="AB"/><extent-class class-ref="A"/></class-descriptor>
<!-- Interface AB -->
<class-descriptor class="AB"> <extent-class class-ref="A"/></class-descriptor>
<!-- Concrete class A -->
<class-descriptor class="A">...</class-descriptor>
<!-- Class with collection property wich references to ABC -->
<class-descriptor class="D" table="CATEGORY">
<field-descriptor name="parentId" column="PARENT_ID" jdbc-type="INTEGER" access="anonymous"/>
<collection-descriptor name="childCategories" element-class-ref="ABC" proxy="true">
<inverse-foreignkey field-ref="parentId"/>
</collection-descriptor>
</class-descriptor>
OJB complains that interface ABC hasn't parentId field because it tries to get descriptor for this property from the first extent class (AB). It doesn't check that AB is an interface to.
thank you for your answer 1
You shouldn't need to specify an extent-class from ABC to A as there is already one to AB which itself has one to A.
i'm using xdoclet. it automatically adds A to extents of ABC
Also, your collection-descriptor refers to a field parentId in 'class' ABC. Therefore you need to declare one there - this also applies to the interface itself, not only the descriptors in the repository.xml. The usual way of handling this is declaring getters/setters in the interface (the java one, not the descriptor) for all properties that you invoke on them (e.g. parentId in the foreignkey, ojbConcreteClass), and also declare them in the descriptor for the interface. Then you must use the PersistentFieldIntrospectorImpl or PersistentFieldAutoProxyImpl for the PersistentField setting since OJB can access the parentId only via bean-properties.
I can't do this because parentId is anonymous field.
Now since OJB must be able to create new objects when reading the collection, you must tell it which concrete class is there. You can either handle this on your own (using factory-class/factory-method for the ABC interface) or you map the interfaces and concrete subclasses to one table (using ojbConcreteClass). Here I'm afraid, mapping to multiple tables does not work.
I use ojbConcreteClass
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
