wenhao / jpa-spec

A JPA Query By Specification framework.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

read lock

kehuixu opened this issue · comments

您好 jpa - spec如何实现read lock呢?

这个本就是Spring Data JPA的功能吧。

public interface SimpleRepository extends JpaRepository<Simple, Long>, JpaSpecificationExecutor<Simple> {
     @Lock(LockModeType.READ)
     public Optional<Simple> findById(Long id);
}

嗯,可是findAll(Specification s)怎么设置呢?

public interface SimpleRepository extends JpaRepository<Simple, Long>, JpaSpecificationExecutor<Simple> {
     @Lock(LockModeType.READ)
     public Page<Simple> findAll(Specification s);
}

thank you for comment