• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

OJB - Two entries in Table after commit

 
Tom Wells
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have the problem that after i make a new object persistence with ojb, it is twice in one of my tables.

My Classes look like that:

Animal<-Cat

The reference_user.xml look like this:

<class-descriptor
class="ojb.test.Animal"
table="animal"
>
<field-descriptor
name="id"
column="Id"
jdbc-type="INTEGER"
primarykey="true"
autoincrement="true"
/>
<field-descriptor
name="race"
column="Race"
jdbc-type="VARCHAR"
/>
</class-descriptor>

<class-descriptor
class="ojb.test.Cat"
table="cats"
>
<field-descriptor
name="id"
column="ID"
jdbc-type="INTEGER"
primarykey="true"
autoincrement="true"
/>

<field-descriptor
name="name"
column="Name"
jdbc-type="VARCHAR"
/>

<reference-descriptor name="super"
class-ref="ojb.test.Animal"
auto-retrieve="true"
auto-update="true"
auto-delete="true"
>
<foreignkey field-ref="id"/>
</reference-descriptor>
</class-descriptor>

And my table schema like this:

CREATE TABLE `animal` (
`Id` int(10) unsigned NOT NULL auto_increment,
`Race` varchar(25) default NULL,
PRIMARY KEY (`Id`)
) TYPE=MyISAM;

CREATE TABLE `cats` (
`Id` int(1) unsigned NOT NULL auto_increment,
`Name` varchar(25) default NULL,
PRIMARY KEY (`Id`)
) TYPE=MyISAM ROW_FORMAT=DYNAMIC;

After i insert a cat object i have one entry in table cats (that is correct) and two entries in the table animal. One of the two entries belongs to the cat table entry the other one has a new id.

I use OJB 1.0.1, jdk1.4.2_3, mysql-connector-java-3.0.9-stable.

Thanks for help,

Tom
 
Tom Wells
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have solved my problem. I removed the id field in the extending class. Now only the root class had the attribute and all works fine. I don't understand why in the inherence description it is written that also the extending classes have the id attribute.

By,

Tom
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic