Why is need Propagation.MANDATORY with PESSIMISTIC_WRITE?

24 Views Asked by At

There is such an example. Do I understand correctly, without MANDATORY this function will mislead the developer? In the sense that without a transaction, despite the name, the locking will not be performed.

interface EmployeRepository extends JpaRepository<Employe, String> {

    @Transactional(propagation = Propagation.MANDATORY)
    @Lock(LockModeType.PESSIMISTIC_WRITE)
    Optional<Employe> findWriteLockedById(String id);
}
0

There are 0 best solutions below