Questions tagged [optimistic-locking]

When coordinating updates from multiple database sessions, optimistic locking is a strategy that assumes all updates can complete without conflict. It does not hold locks on any records while the user is editing, but checks to see if any other edits have occurred when the user tries to commit the changes. If two sessions try to edit the same data, the second one to commit will be rejected and have to redo the change. Also see pessimistic locking.

422 questions
0
votes
0 answers

Otpimistich Lock get All Conflicting entities

try{ .... }catch(ObjectOptimisticLockingFailureException e){ e.getIdentifier(); -> this is just one id of conflicting entity. } How to get all conflicting entities??? What about this solution ? List ids =…
idmitriev
  • 4,619
  • 4
  • 28
  • 44
0
votes
1 answer

Hibernate Optimistic Lock method

I have an entity : @Entity public class Client { ..... @Version @Column(name="OPTLOCK") private long version; } Now Optimistic lock is always working, now each method can throw a ObjectStaleStateException BUT, if I want to make…
idmitriev
  • 4,619
  • 4
  • 28
  • 44
0
votes
1 answer

Castle ActiveRecord optimistic locking on properties

Can Castle ActiveRecord do optimistic locking on properties? I found optimistic locking for the entire class, but not for an individual property. In my case, I need to make it so that adding/removing elements in a collection does not update the…
Daniel T.
  • 37,212
  • 36
  • 139
  • 206
0
votes
1 answer

Optimistic Locking doesn't work - no version increment, no exception

I'am using org.springframework.data.repository.CrudRepository to save my entities. Here is my entity: @Entity @Table (name="ThirdClass") public abstract class ThirdClassBase extends BaseDomainObject implements Serializable, Cloneable{ …
user3227576
  • 554
  • 8
  • 22
0
votes
1 answer

Concurrent transaction issue on clustered environment

I have came across one scenario in web application which runs on clustered environment. We have 2 nodes(both has JVM) Node1 Node2 I am running one database transaction in my application where sequence_no is read and later we increment it with…
DeepInJava
  • 1,871
  • 3
  • 16
  • 31
0
votes
2 answers

GAE update different fields of the same entity

UserA and UserB are changing objectA.filedA objectA.filedB respectively and at the same time. Because they are not changing the same field one might think that there are no overlaps. Is that true? or the implementation of pm.makePersistnace()…
0
votes
1 answer

Optimistic locking and overriding

I am getting difficulties when trying to understand how can version-based optimistic locking prevent "last-commit-wins" issue and appropriate overriding. To make the question more concrete, let's consider the following pseudo-code that uses…
0
votes
0 answers

JPA flush() in concurency OptimisticLock

I have problem with flush() method in entityManager. In my application I'm modifying object and after that I call em.flush() but I dont commit() changes, in the same time second user is modifying the same object and at the end he also calls…
bojek
  • 63
  • 2
  • 5
0
votes
1 answer

Snapshot Isolation - perform validations in transaction while maintaining ability to rollback

I am looking into SQL Server Snapshot isolation level. For simple updates, things seem straightforward and you can find lots of examples of how to handle. However, for logic which relies on data validation checks at the end of the transaction, I'm…
0
votes
1 answer

Common exception handling for rolled back transactions

We have an application using Java and Hibernate. We use optimistic locking and a relational database. We have a common situation where we have a pool of resources, that two different users try to modify at the same time. One user is able to edit the…
user1340582
  • 19,151
  • 35
  • 115
  • 171
0
votes
2 answers

Hibernate one-to-many sql execution order

I have two hibernate entities: Order and its Items (one-to-many with save-update cascade, nothing special). Two users initiate an update of the same Order by adding a new Item at the same time which triggers Session.saveOrUpdate(order) operation in…
ike3
  • 1,760
  • 1
  • 17
  • 26
0
votes
1 answer

Implementing Optimistic locking in Hibernate using @Version or LockMode.OPTIMISTIC or both

I read that we can implement optimistic locking in hibernate using version field using @Version. Then on reading about pessimistic locking, I came to know that org.hibernate.LockMode class which has some options like LockMode.OPTIMISTIC etc which we…
Anand
  • 20,708
  • 48
  • 131
  • 198
0
votes
0 answers

JPA Sequence generator Primary key set to null

I am trying to generate a primary key using Sequence generator in JPA and all the parameters are properly set as shown @Id @Column(name = "TEST_ID", unique = true, nullable = false, precision = 12) @GeneratedValue(strategy =…
Kesavacharan
  • 318
  • 3
  • 14
0
votes
1 answer

Optimistic locking in vaadin and mysql db

The Vaadin book says I can set a column for optimistic locking as follows: tq.setVersionColumn("OPTLOCK"); However it also says that: TableQuery assumes that the database will take care of updating the version column by either using an actual …
Santiago
  • 982
  • 3
  • 14
  • 30
0
votes
0 answers

How do I control the "original version" for optimistic concurrency in EF?

EF has built-in support for optimistic concurrency (http://msdn.microsoft.com/en-us/data/jj592904.aspx). In this case, I want to leverage that capability, but I don't want the "before" object to be what I just pulled from the database. Instead, I…
Scott Stafford
  • 43,764
  • 28
  • 129
  • 177