교착 상태에 빠지지 않게 하기 위해 비관점 잠금 타임아웃을 설정할 수 있다. 

Map<String, Object> hints = new HashMap<>();
hints.put("javax.persistence.lock.timeout", 2000);
Order order = entityManager.find(Order.class, LockModeType.PESSIMISTIC_WRITE, hints);

 

@Lock(LockModeType.PESSIMISTIC_WRITE)
@QueryHints({
	@QueryHint(name="javax.persistence.lock.timeout", value="2000" )
})
@Query("select m from Member where m.id = :id")
Optional<Member> findByIdForUpdate(@Param("id") MemberId memberId);

+ Recent posts