I found a workaround, but i will decrease performance dramatically.
Instead of doing a
broker.store(a);
I do the following:
Identity id = new Identity(a, broker);
A oldA = broker.getObjectByIdentity(id);
broker.delete(oldA);
broker.store(a);
If i usie only the store call (which leads to data inconsistency) the sql
statements executed are
the following ones:
update a ... // update object a
insert into b ... // store b collection, without removing old
ones...
When using the workaround, the following statements are executed:
delete from b ... // delete collection of B
delete from a // delete object A
select ... from a // the object is not in cache anymore, so
materialize it
insert into a ... // insert a
select ... from b // check materializing b
insert into b ... // insert into b
Which is not optimal at all.
I'd like to have the following statement:
delete from b ... // remove old collection of b
update a ... // update object a
insert into b ... // insert new collection
Can anyone give me a hint the problem ?
-----Message d'origine-----
De : Guillaume Nodet [mailto:[EMAIL PROTECTED]
Envoye : mardi 3 fevrier 2004 10:12
A : OJB Users List
Objet : Problem updating objects with collections
Here is my problem:
I've got an object of class A with a collection of objects of class B.
I receive fresh new objects to update from a source that is not ojb.
When i want to update the object of class A the following operations
are performed (let say i have only one B object in the collection):
* update of row in the A table
* insert a row in the B table
My problem is that ojb do not delete the old B collection.
I checked the PersistenceBrokerImpl code, but i did not see anything
about deleting objects in collections that are not here anymore.
Regards
Guillaume Nodet
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]