Table indexes/pk for Optimistic Locking in JPA <p>What is the best practice for defining table indexes for entities supporting optimistic locking?</p> <p>For sure, entity id has to be part of some index in DB to enable fast lookups by id. What about version column? Does it make sense to make it part of an index?</p> <p>What if we do not define DB primary key, but create an index consisting of entity id + version column? Any risk of having two rows in DB with same entity id? Say two transactions persist two entities with the same entity id in parallel?</p>