Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Optimistic Locking since 2.4x(The SQL creation seems to have changed since Version 2.3x)
Optimistic Locking since 2.4x [message #1105939] Tue, 10 September 2013 13:18
Torsten Löhr is currently offline Torsten LöhrFriend
Messages: 1
Registered: September 2013
Location: Germany
Junior Member

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...
  • Attachment: diagram.svg
    (Size: 1.35MB, Downloaded 97 times)
  • Attachment: BHPTools.java
    (Size: 27.75KB, Downloaded 98 times)
Previous Topic:Patch for Memoryleak
Next Topic:@CacheIndex doesn't work with Criteria Query
Goto Forum:
  


Current Time: Sat Dec 20 06:00:41 GMT 2014

Powered by FUDForum. Page generated in 0.01531 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software