Hello everybody,
I am using Eclipselink 2.3x for two years now and have gained some experience with it. The software project I am working on uses the optimistic locking mechanism via @Version long columns.
Every day there a couple of records to be created according to some scheme which is stored in a different table. This "schedule" table has a 1:n relation to a base table. And so on.
During the creation of the new records I lock the underlying base tables as FORCE_INCREMENT to prevent conflicts during this very senstitive process.
Entities in "BHP" are created. The related tables "Prescription", "PrescriptionSchedule" and "Resident" are locked like this:
em.lock(pSchedule, LockModeType.OPTIMISTIC_FORCE_INCREMENT);
em.lock(em.merge(pSchedule.getPrescription()), LockModeType.OPTIMISTIC_FORCE_INCREMENT);
em.lock(pSchedule.getPrescription().getResident(), LockModeType.OPTIMISTIC);
With EclipseLink 2.3x only these tables are "optimistically" locked causing a SQL code (MySQL btw.) like this:
UPDATE resident SET version = ? WHERE ((BWKennung = ?) AND (version = ?))
bind => [1, SE2, 1]
UPDATE prescription SET version = ? WHERE ((VerID = ?) AND (version = ?))
bind => [201, 4660, 200]
With EclipseLink 2.4x the creation of the SQL code changes notably. Now, even not directly locked (even though otherwise related) tables are "FORCE_INCREMENTED", too. This code was not created with the 2.3x.
UPDATE users SET version = ? WHERE ((UKennung = ?) AND (version = ?))
bind => [3, tloehr, 2]
The Table "users" is not locked in the code. But it seems to be cascaded somehow. Same goes for the tables "Resident", "Homes" and others.
I don't understand this. I realize that this may be a complicated description.
I added a complete ER Diagram as SVG with this post (see attached).
The code for the specific creation part starts at line 228 in the attached java file.
Bye, Torsten...