Hi Matthieu,

Did you try to use cascade-update="true" on a reference to the collection of 
objects (M part in 1:M relationship) you are trying to update?

Sergey





-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Friday, October 07, 2005 7:53 AM
To: ojb-user@db.apache.org
Subject: problems with autoincrement tables





Dear fellow ojb users,
i faced a problem with ojb:
 if you have a class A with the id of the column which is autoincremented,
when you create a new object foo instance of A .
OJB insert all the column excepted the autoincremented one, then fetch in
the database the id of the newly stored object and set the Id in the
object.
When you insert an object with an id, OJB insert the object without the ID
specified so the id is not the same in the database and in the object
because in this case OJB don't fetch the new ID and don't update the
object.

With our DB2 z/OS database we are sometimes obliged to delete/insert object
instead of updating the object (it's mandatory when of the updated column
is a key of a partitionned table).
In this case we fetch our object from the database, delete it, update the
bean and store the object in the database. As it has been deleted OJB
realize that the object need to be inserted (and not updated) but doesn't
update the id of the java object.
In a 1 to N relation this side effect is harmless but if you have
inheritance in the database or a M to N relation then it's a big problem
because when you insert the whole relation there are foreign key violation
because of the difference of value between the bean and the database.

Is this problem easy to solve ?


Matthieu PATOU

DINQ/DSIN/SIDM/VNVO/VOIN
Téléphone 01 30 19 17 91  (29 17 91)


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


**********************
** LEGAL DISCLAIMER **
**********************

This E-mail message and any attachments may contain
legally privileged, confidential or proprietary
information. If you are not the intended recipient(s),
or the employee or agent responsible for delivery of
this message to the intended recipient(s), you are
hereby notified that any dissemination, distribution
or copying of this E-mail message is strictly
prohibited. If you have received this message in
error, please immediately notify the sender and
delete this E-mail message from your computer.

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

Reply via email to