67,528
社区成员
![](https://csdnimg.cn/release/cmsfe/public/img/topic.427195d5.png)
![](https://csdnimg.cn/release/cmsfe/public/img/me.40a70ab0.png)
![](https://csdnimg.cn/release/cmsfe/public/img/task.87b52881.png)
![](https://csdnimg.cn/release/cmsfe/public/img/share-circle.3e0b7822.png)
@Lock(value = LockModeType.PESSIMISTIC_READ)
@Query(value="select t from TBlvcAccessIpConfig t")
public List test1();
通过添加Lock注解即可,发现发送的查询语句后面会带上for update,即使用了数据库本身的锁机制。如果对JPA不熟采用直接写SQL的形式也是可以的
@Transactional
@Query(value="select * from t_blvc_access_ip_config for update",nativeQuery=true)
public List test1();