• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

OJB - Two entries in Table after commit

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Space pants. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic