• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: lockRowComparingAttributes (yet again)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: lockRowComparingAttributes (yet again)


  • Subject: Re: lockRowComparingAttributes (yet again)
  • From: Chuck Hill <email@hidden>
  • Date: Thu, 4 Aug 2005 08:41:44 -0700


On Aug 4, 2005, at 12:48 AM, Ian Joyner wrote:

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

That right there looks wrong. SELECT...FOR UPDATE strongly suggests that something is wrong with your model. The first two things to check are:
1. Are the Value Type and Value Class (Java) set / set correctly for each attribute in the table?
2. Have you recently switched databases and have the old jdbc2info in the model's connection dictionary?
3. Do the PK / FK definitions on the keys in Person, Asset, and Telephone match _exactly_? Exactness counts. :-)



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

I'd guess that you have a mismatch between the model and your database or between the PK or FK definitions on two related entities. Check the Scale and Precision. Is asset_type_key really supposed to be a floating point number? This error will happen if you are using BigDecimal and the Scale as created does not match the Scale as fetched or if you do math and the scale is not set correctly on the result.



[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._exceptionWithDatabaseContext InformationAdded(EODatabaseContext.java:4686)
    at com.webobjects.eoaccess.EODatabaseContext.performChanges(EODatabaseCont ext.java:6394)
    at com.webobjects.eocontrol.EOObjectStoreCoordinator.saveChangesInEditingC ontext(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,

That is not going to help. The error is not "can't find the row in the DB" but "found the row and the values fetched don't match the values previously cached". Note this is ALL the values not just what is in the WHERE clause. From your description, this is a modeling / code error, not a true optimistic locking failure (well, unless something else is writing to the DB).


Test it out like this: insert a new object. Stop and restart the app. Edit the object. Does that go OK? If so, the error is in your model / code.

Chuck


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


--
Practical WebObjects - a book for intermediate WebObjects developers who want to increase their overall knowledge of WebObjects, or those who are trying to solve specific application development problems.
http://www.global-village.net/products/practical_webobjects




_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: lockRowComparingAttributes (yet again)
      • From: Ian Joyner <email@hidden>
References: 
 >lockRowComparingAttributes (yet again) (From: Ian Joyner <email@hidden>)

  • Prev by Date: Re: How to find out about installed WO Version
  • Next by Date: Child Editing Contexts -- locking/unlocking
  • Previous by thread: lockRowComparingAttributes (yet again)
  • Next by thread: Re: lockRowComparingAttributes (yet again)
  • Index(es):
    • Date
    • Thread