• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

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
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic