Cédric,


You need to define the attribute persistent-capable-superclass in your .jdo file for the sub-class. So if you have class A extends class B, your .jdo file would have:

<class name="B" persistence-capable-superclass="A">

The JDORI enhancer creates final methods to access the persistent attributes of the object. If it does not know that B is a subclass of A, it will define them for both B and A, which will result in the error you see. If A has an attribute z, then you should list it only in the <class> section of A. Since B is a subclass of A, it will inherit the getter/setters that JDORI creates for z. Only define B's unique attributes in the <class> section for B. Like so:

<class name="A">
        <field name="z">
        <field name="y">
</class>
<class name="B" persistence-capable-superclass="A">
        <field name="x">
</class>



Cédric Pineau wrote:


Hello,



I'm trying to use OJB through JDO and have a problem with basic inheritance between two persitent class : I get " class entities.Statute2 overrides final method . java.lang.VerifyError: class entities.Statute2 overrides final method . at java.lang.ClassLoader.defineClass0(Native Method) ... " at runtime when the classloader loads the Statute2 class.

 Statute2 inherits from Statute (this actually a test drive :-) Here is
my code :


Statute :

package entities;
public class Statute {
protected int id;
public int getId() {
return this.id;
}
public void setId(int id) {
this.id = id;
}
/** default constructor */
public Statute() {}
/** full constructor */
public Statute(java.lang.String name) {
this.name = name;
}
protected java.lang.String name;
public java.lang.String getName() {
return this.name;
}
public void setName(java.lang.String name) {
this.name = name;
}
public String toString() {
return "Statute "+this.name+" (id = "+this.id+")";
}
}



Statute 2 :

package entities;
public class Statute2 extends Statute {
/** default constructor */
public Statute2() {}
/** full constructor */
public Statute2(java.lang.String name, String name2) {
this.name = name;
this.name2 = name2;
}
protected java.lang.String name2;
public java.lang.String getName2() {
return this.name2;
}
public void setName2(java.lang.String name2) {
this.name2 = name2;
}
public String toString() {
return "Statute "+this.name+" "+this.name2+" (id = "+this.id+")";
}
}


repository_user.xml :
<class-descriptor class="entities.Statute" table="STATUTE">
<extent-class class-ref="entities.Statute2" />
<field-descriptor name="id" column="ID" jdbc-type="INTEGER"
primarykey="true" autoincrement="true"/>
<field-descriptor name="name" column="NAME" jdbc-type="VARCHAR"/>
</class-descriptor>
<class-descriptor class="entities.Statute2" table="STATUTE2">
<field-descriptor name="id" column="ID" jdbc-type="INTEGER"
primarykey="true" autoincrement="true"/>
<field-descriptor name="name" column="NAME" jdbc-type="VARCHAR"/>
<field-descriptor name="name2" column="NAME2" jdbc-type="VARCHAR"/>
</class-descriptor>


entities.jdo (partial) :
...
    <class name="Statute">
      <extension vendor-name="ojb" key="table" value="Statute"/>
      <field name="id">
        <extension vendor-name="ojb" key="column" value="id"/>
      </field>
      <field name="name">
        <extension vendor-name="ojb" key="column" value="name"/>
      </field>
    </class>
    <class name="Statute2">
      <extension vendor-name="ojb" key="table" value="Statute2"/>
      <field name="name2">
        <extension vendor-name="ojb" key="column" value="name2"/>
      </field>
    </class>
...

sql for table creation (postgresql) :
CREATE TABLE STATUTE (
ID INT PRIMARY KEY,
NAME TEXT
);
CREATE TABLE STATUTE2 (
ID INT PRIMARY KEY,
NAME TEXT,
NAME2 TEXT
);



I suppose I did something wrong but can't figure what. I already tried to enhance only one of the two, to remove id and name
from Statute2 class-desciptor entry but...


 Can someone light my way to the wonderful world of JDO ?
 Thanks,

Cédric






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



Reply via email to