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

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -