I'm having some trouble using the PersistenceBroker store method on an object mapped with a simple inheritance hierarchy.

Here's how my classes are configured:

public class Person
{
   private String oid;
   private String lastName;
   private String firstName;
   // (setters and getters....)
}
public class Student extends Person
{
   private String oid;
   private String grade;
   private String homeroom;
   // (setters and getters....)
}

<class-descriptor class="Person" table="PERSON">
<field-descriptor name="oid" column="OID" jdbc-type="CHAR" primarykey="true" />
<field-descriptor name="lastName" column="LAST_NAME" jdbc-type="VARCHAR" />
<field-descriptor name="firstName" column="FIRST_NAME" jdbc-type="VARCHAR" />
</class-descriptor>
<class-descriptor class="Student" table="STUDENT">
<field-descriptor name="oid" column="OID" jdbc-type="CHAR" primarykey="true" />
<field-descriptor name="grade" column="GRADE" jdbc-type="VARCHAR" />
<field-descriptor name="homeroom" column="HOMEROOM" jdbc-type="VARCHAR" />
<reference-descriptor name="super" class-ref="Person" auto-update="true">
<foreignkey field-ref="oid" />
</reference-descriptor>
</class-descriptor>


If I insert values for the two tables into the database directly, I am able to query on the Student class successfully through OJB. I can also update pre-existing objects using the store method. When I try to create a new Student object, however, I get the following exception:

org.apache.ojb.broker.PersistenceBrokerException: assertValidPkFields failed for Object of type: Person on insert
at org.apache.ojb.broker.core.PersistenceBrokerImpl.storeToDb(PersistenceBrokerImpl.java:1999)


It appears that OJB isn't assigning the oid to the new Person object. Am I missing something in my mapping? Is it even possible to insert both the PERSON and STUDENT records at the same time by storing a new Student object?

Thanks for your help.

Matt




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



Reply via email to