OK, I have read all the past mails on this issue trying to solve this problem. I have a person entity where generic person attributes are stored in a PERSON table and specific attributes are stored in a subclass table (called ASSET). I create and store one of these entities, then add a telephone number for them (stored in a separate TELEPHONE table). The SQL generated for the original save is:
[2005-08-04 17:13:03 EST] <WorkerThread1> evaluateExpression: <com.webobjects.jdbcadaptor.OpenBasePlugIn$OpenBaseExpression: "INSERT INTO PERSON(PRIMARY_KEY, GENDER_KEY, PERSON_TYPE_KEY, DATE_OF_BIRTH, TERMINATION_DATE, UNIQUE_ID, CREATION_DATE, ALIAS, MODIFICATION_DATE, TYPE, TITLE_KEY, FIRST_NAME, SURNAME, MIDDLE_NAMES) VALUES (?, ?, ?, NULL, NULL, NULL, ?, NULL, ?, ?, ?, ?, ?, NULL)" withBindings: 1:4(NeededByEOF0), 2:6.0(gender_key), 3:12.0(person_type_key), 4:2005-08-04 17:13:03(creation_date), 5:2005-08-04 17:13:03(modification_date), 6:"A"(type), 7:1.0(title_key), 8:"tyu"(first_name), 9:"tyu"(surname)>
[2005-08-04 17:13:03 EST] <WorkerThread1> evaluateExpression: <com.webobjects.jdbcadaptor.OpenBasePlugIn$OpenBaseExpression: "INSERT INTO ASSET(HEALTH_FUND_NUMBER, PRIMARY_KEY, HEALTH_FUND_EXPIRY_DATE, PLAYER_NUMBER, HEALTH_FUND, ASSET_TYPE_KEY, MEDICAL_EXPIRY_DATE, MEMBER_ID, IS_A_DOCTOR, CLUB, MEDICAL_NUMBER, IS_A_MANAGER) VALUES (NULL, ?, NULL, NULL, NULL, ?, NULL, NULL, NULL, NULL, NULL, NULL)" withBindings: 1:4(primary_key), 2:13.0(asset_type_key)>
When I attempt to save the new telephone record, I get:
[2005-08-04 17:13:24 EST] <WorkerThread3> evaluateExpression: <com.webobjects.jdbcadaptor.OpenBasePlugIn$OpenBaseExpression: "SELECT t0.PRIMARY_KEY FROM ASSET t0, PERSON T1 FOR UPDATE WHERE (T1.TYPE = ? AND (t0.PRIMARY_KEY = ? AND t0.MEMBER_ID is NULL AND t0.ASSET_TYPE_KEY = ? AND t0.PLAYER_NUMBER is NULL AND t0.CLUB is NULL AND t0.MEDICAL_NUMBER is NULL AND t0.MEDICAL_EXPIRY_DATE is NULL AND t0.HEALTH_FUND is NULL AND t0.HEALTH_FUND_NUMBER is NULL AND t0.HEALTH_FUND_EXPIRY_DATE is NULL AND t0.IS_A_DOCTOR is NULL AND t0.IS_A_MANAGER is NULL)) AND t0.PRIMARY_KEY = T1.PRIMARY_KEY" withBindings: 1:"A"(type), 2:4(primary_key), 3:13.0(asset_type_key)> [2005-08-04 17:13:24 EST] <WorkerThread3> 1 row(s) processed [2005-08-04 17:13:24 EST] <WorkerThread3> === Rollback Internal Transaction [2005-08-04 17:13:24 EST] <WorkerThread3> Server exception: lockRowComparingAttributes -- com.webobjects.jdbcadaptor.JDBCChannel: lock operation fetched row with different values than snapshot [2005-08-04 17:13:24 EST] <WorkerThread3> com.webobjects.eoaccess.EOGeneralAdaptorException: lockRowComparingAttributes -- com.webobjects.jdbcadaptor.JDBCChannel: lock operation fetched row with different values than snapshot at com.webobjects.eoaccess.EODatabaseContext._exceptionWithDatabaseContextInformationAdded(EODatabaseContext.java:4686) at com.webobjects.eoaccess.EODatabaseContext.performChanges(EODatabaseContext.java:6394) at com.webobjects.eocontrol.EOObjectStoreCoordinator.saveChangesInEditingContext(EOObjectStoreCoordinator.java:415)
lockRowComparingAttributes has found a single record, so that is OK, but it must fail on the comparison. Now I have also turned off attribute locking on every attribute, so that lockRowComparingAttributes only retrieves the bare minimum:
SELECT t0.PRIMARY_KEY FROM ASSET t0, PERSON T1 FOR UPDATE WHERE (T1.TYPE = ? AND (t0.PRIMARY_KEY = ? AND t0.ASSET_TYPE_KEY = ?)) AND t0.PRIMARY_KEY = T1.PRIMARY_KEY" withBindings: 1:"A"(type), 2:49(primary_key), 3:13.0(asset_type_key)
and this still fails.
Is there a problem with optimistic locking and inheritance? Any other factor that might be causing this, because I think I have tried every other suggestion from past posts.
Thanks Ian Joyner Sportstec
|