Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

TOPLINK

 
Mythili Sathya
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was trying to update same column simultaneously using toplink. For example let me trying to update Column BILL_NBR ,incrementing the value by 1

First thread fetches the record. Example BILL_NBR = 1
First thread has successfully updated the column to BILL_NBR = 2;

The second thread fetches the updated record correctly .BILL_NBR=2;

But the query formed in the update logic is as follows.

UPDATE << TABLE_NAME >> SET BILL_NBR = 3 WHERE ((<< PKY >> = << SOME VALUE >>) AND (BILL_NBR = 1))

The where clause is taking the old BILL_NBR value.

I am updating the values as follows.
uow.registerNewObject(<<TABLE_NAME>>);

Any solution for the same.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure I understand what the issue is. You seem to be saying that you update a record simultaneously from two threads and it works?

Also, the update query you are using, does PKY stand for the primary key? If it does, why is anything else in your where clause? (since anything else is redundant).
[ September 11, 2008: Message edited by: Paul Sturrock ]
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you checked you caching? ORM mapping layers aren't required to go to the database and can store some changes in memory and flush the nett result to the DB in one operation. If this is the case then the SQL makes sense.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note we have a separate forum for Object Relational Mapping frameworks. I'll move this for you.
 
Mythili Sathya
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The query is been formed by the toplink.As per the analysis the values are taken from the cache object and not from the database

I used uow.unregisterObject(<<OBJECT_NAME>> ;

And this solved my issue.But i want suggestion for the same.
Is this the right way to clear Object from the cache and the force to the code to retrive from database rather from the cache?

Is there any other way to clear cache value in Toplink?
 
James Sutherland
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you wish to refresh an object use the refreshObject() API.

You can also configure the cache as you desire, or disable it using an isolated cache.

Are you using field-level optimistic locking?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic