Both (a) transaction isolation levels and (b) JPA lock modes are enforced using DBMS' locks on tables/rows. What will happen if I set (a) not to check any locks and (b) to check some, or vice versa? Which takes precedence?
Example (using Spring):
@Transactional(isolation = Isolation.READ_UNCOMMITTED)
public void incrementVal(int primaryKey) {
SomeEntity e = entityManager.find(
SomeEntity.class, primaryKey, LockModeType.PESSIMISTIC_WRITE);
int val = e.getVal();
e.setVal(val + 1);
}
Or, reversing the constraints:
@Transactional(isolation = Isolation.SERIALIZABLE)
public void incrementVal(int primaryKey) {
SomeEntity e = entityManager.find(
SomeEntity.class, primaryKey, LockModeType.NONE);
int val = e.getVal();
e.setVal(val + 1);
}
This is obviously not a real problem, but I'm trying to understand how these work, and their interplay. Thanks!