Is there a way to save objects to business data without the Row was updated or deleted error?

1
0
-1

I have a problem since a few months, tried many things to counter this error, but i just cant make it work.

The error: javax.persistence.OptimisticLockException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect)

I know why this keeps happening, i have a Client business data object, that has a list of Car objects, and the Car objects have Services.

I have about 10 000 Cars but only 100 Services, many cars have the same Services, and when i try to modify more than one car with the same Service, this error comes up. I understand that by modifying a Car attribute in the database adds 1 version to the Car, but Bonita adds version to the Service as well, even if i don't touch it at all. It probably does it because the framwork doesn't check if it was modified or not, it simply updates the service as well.

A real world scenario, i set a timer for 10 Cars with the same Service in 10 different processes, the timer is set for tomorrow, and after the timer is up i want to change the state of the 10 cars to deleted or something else. Then i will get this error on 00:00 AM because every process will advance at the same time, the first to finish the modification will succeed, the rest will fail with transient exception or the exception i mentioned above.

Is there a way to set this behavior?

Because this way the framework is unusable, if i cannot modify two different objects at the same time just because they have a common child object that isn't supposed to be updated.

I made some workarounds, like in every task i load the database object in to business data just before modifying the object, but this doesn't work if two processes start the modification at the same time.

Every help is appreciated.

No answers yet.
Notifications