read lock
kehuixu opened this issue · comments
kehuixu commented
您好 jpa - spec如何实现read lock呢?
Wen Hao commented
这个本就是Spring Data JPA的功能吧。
public interface SimpleRepository extends JpaRepository<Simple, Long>, JpaSpecificationExecutor<Simple> {
@Lock(LockModeType.READ)
public Optional<Simple> findById(Long id);
}
kehuixu commented
嗯,可是findAll(Specification s)怎么设置呢?
Wen Hao commented
public interface SimpleRepository extends JpaRepository<Simple, Long>, JpaSpecificationExecutor<Simple> {
@Lock(LockModeType.READ)
public Page<Simple> findAll(Specification s);
}
kehuixu commented
thank you for comment