Hi,
unfortunately I still have one problem:
I use a xml-parser to pre-validate the repository.xml-file. This Parser now complains that field-descriptors cannot be used when using extent. I checked that with the DTD and I think it is correct:
<!ELEMENT class-descriptor
((documentation?, extent-class+, attribute*) |
(documentation?, object-cache?, extent-class*, field-descriptor+,
reference-descriptor*, collection-descriptor*,
index-descriptor*, attribute*,
insert-procedure?, update-procedure?, delete-procedure?))>But the thing is: OJB works correctly. So what do I do now? Should I ignore this warning? Or do I have to create a not-persistent abstract
superclass?
Tino
Thomas Dudziak wrote:
Tino Sch�llhorn wrote:
Hi,
I have I inheritance-problem. I want to map two classes to one table. They are defined as followed:
class A { int id; protected String ojbConcreteClass; // some attributes }
class B extends A { // some additional attributes }
I created class-descriptors for each of the table:
<class-descriptor class="A" table="table"> // field-descriptors for A inluding ojbConcreteClass </class>
and
<class-descriptor class="B" table="table" extends="A"> // additional field-descriptors for B </class>
So: When I try to store an instance of Type A everything is fine. But when I try to store an instance of Type B OJB complains:
Caused by: org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException: OJB needs at least one primary key attribute for class objectsRealClass=class kos.wnetz.om.RelationHistoryEvent, objectTopLevelClass=class kos.wnetz.om.RelationHistoryEvent
at org.apache.ojb.broker.Identity.checkForPrimaryKeys(Identity.java:245)
at org.apache.ojb.broker.Identity.init(Identity.java:121)
So I also tried to include the field-descriptors of the superclass in the class-descriptor for class B. But then I get an even worse error:
Caused by: java.sql.SQLException: Parameter index out of range (8 > 7).
I don't know where this exception comes from, but in order to describe a super-subtype relationship you should use something like:
<class-descriptor class="A" table="table"> <extent-class class-ref="B"/> // field-descriptors for A inluding ojbConcreteClass </class>
and
<class-descriptor class="B" table="table"> // field-descriptors for B including ojbConcreteClass </class>
The extent-class is inverse to the extends/implements in Java (i.e. specified at the supertype), and also note that the class-descriptor for B contains all attributes of A (there is no automatic 'inheritance' of the descriptors in the repository.xml file) including the ojbConcreteClass attribute.
Tom
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
