java - Optimistic locking on merge operation using JPA -
java - Optimistic locking on merge operation using JPA -
i have production code running past 2 years. have noticed there concurrency issue in update operation. using jpa orm. in update request using
this.entitymanager.merge(entity);
now want utilize optimistic lock avoid concurrency. have done searching in google. think next take care
this.entitymanager.lock(entity, lockmodetype.optimistic);
here uncertainty need @version in table. guess client won't agree in adding column now.
can tell me there improve way handle scenario.
well, in jpa, no. jpa uses version column maintain it's consistency , there doesn't appear way around that.
in hibernate there semantics around this:
optimistic-lock = ‘all’
when set optimistic-lock attribute on element in hibernate mapping file value ‘all’, telling hibernate check no column in associated row has changed since persistent object retrieved , before updating row in database.
read more: http://www.intertech.com/blog/hibernate-optimistic-lock-without-"
java hibernate jpa
Comments
Post a Comment