Matt,

I had the same problem. Here is my post, you can read through the thread for the history. Jakob made a patch and put it in cvs, so you will need to get the latest cvs if you want to use this approach. So, try adding autoincrement to Person and build ojb from cvs.

http://www.mail-archive.com/[EMAIL PROTECTED]/msg04473.html


-chris worley


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]




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



Reply via email to