Spring JPA 使用 NOT IN 查询

List<String> useridList = new ArrayList<>(); //需要注意的是这个位置  new ArrayList<>();  useridList 存的是 not in 中的参数
Repository 接口中方法

第一种带分页

public Page<UserEntity> findByIdNotIn(List<String> list, Pageable page);

第二种不带分页

public List<UserEntity> findByIdNotIn(List<String> list);

第三种不带分页

@Query(nativeQuery =true,value = "SELECT * FROM   table as u where u.id NOT IN (?1)  order by u.createTime )
public List<UserEntity> findAllcs( List<String> uIds);
发布了11 篇原创文章 · 获赞 4 · 访问量 6016

猜你喜欢

转载自blog.csdn.net/qq_15304369/article/details/103066492