Does anyone know why Spring does not allow to put @Lock(LockModeType.PESSIMISTIC_WRITE) on read operations?
@Lock(LockModeType.PESSIMISTIC_WRITE)
Human findByNameAndStreet(String name, String street);
And also why EntityManager itself allows you to put exclusive lock on read operation?
entityManager.createQuery("select o from Human o where o.name= :name and o.street= :street", Human.class)
.setLockMode(LockModeType.PESSIMISTIC_WRITE).setParameter("name", name).setParameter("street", street).getSingleResult();
Bottom line, on same select query in Spring I can't put WRITE lock, and with EntityManager I'm able. I don't really know why Spring does not let you do same thing.