Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JPA Pessimistic Locking or Serializable Transaction Isolation

843830Feb 9 2009 — edited Feb 12 2009
Hi All,

I am looking for some advice on achieving mutual exclusion over objects using JPA. I am using MySQL with innodb (supports row level locking).
I would like to be able to make use of the row level locking in MySQL, but it seams that JPA only supports optimistic locking by default.

I am developing a desktop application that will be used by multiple users at the same time...

I'd like the application to allow any number of users to view records but only allow one user at a time to have a write lock on any one record.

Optimistic locking doesn't appeal very much at all as it may be difficult to merge changes and would likely annoy users if they had to re-enter data, rather it would be better if they know they could not make edits, or rather only one user at a time.

I have read the following: http://en.wikibooks.org/wiki/Java_Persistence/Locking

which gives a good explanation of options available. I am currently using Hibernate as my persistence provider though I would be willing to move to another if needed as I understand that toplink/eclipselink may support pessimistic locking. Also though it would be good if any one could tell me more about JPA and Serializable Transaction Isolation as this would work quite well from what I have read.

Any suggestions, comments, solutions are much appreciated.

Thanks

Paul
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 12 2009
Added on Feb 9 2009
1 comment
680 views