title: Read only transaction table locking
body: <p>I'm using JPA 2.0, Hibernate and MySQL. The isolation of MySQL db is TRANSACTION_REPEATABLE_READ. I have a set of queries which will be used for displaying data on the website. Some of those queries will have to fetch a lot of rows and they can be modified in the middle by some other process. Do I have to use any kind of locking (pessimistic or optimistic) for those read only queries to make sure that the result set will be consistent?</p>
  
  <p>Does using optimistic locking with auto object versioning via @Version annotation make any sense for read only queries?</p>
  
  <p><strong>I'm not sure why would ever anybody have to explicitly specify LockModeType.OPTIMISTIC on entity or query. If the object is versioned it will be checked on commit anyway, right?</strong></p>