Commit 0ca907cb authored by xiaoguang.xu's avatar xiaoguang.xu

limit 换成between and

parent 3203ce6f
...@@ -51,7 +51,7 @@ public class SyncHashController { ...@@ -51,7 +51,7 @@ public class SyncHashController {
Long startPosition = startUserId; Long startPosition = startUserId;
while (isContinue) { while (isContinue) {
Long endPosition = startPosition + step; Long endPosition = startPosition + step;
List<User> users = userRepository.findBtIdBetween(startPosition, endPosition); List<User> users = userRepository.findByIdBetween(startPosition, endPosition);
if (users.isEmpty()) { if (users.isEmpty()) {
log.info("没有数据了. 结束了"); log.info("没有数据了. 结束了");
return; return;
......
...@@ -50,6 +50,6 @@ public interface IUserRepository extends JpaRepository<User, Long>, JpaSpecifica ...@@ -50,6 +50,6 @@ public interface IUserRepository extends JpaRepository<User, Long>, JpaSpecifica
@Query(value = "select * from user where id >= ?1 limit ?2", nativeQuery = true) @Query(value = "select * from user where id >= ?1 limit ?2", nativeQuery = true)
List<User> findByIdLimit(Long id, Long limit); List<User> findByIdLimit(Long id, Long limit);
List<User> findBtIdBetween(Long id, Long endId); List<User> findByIdBetween(Long id, Long endId);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment