Commit 3203ce6f authored by xiaoguang.xu's avatar xiaoguang.xu

limit 换成between and

parent c0a457e0
......@@ -50,7 +50,8 @@ public class SyncHashController {
.execute(() -> {
Long startPosition = startUserId;
while (isContinue) {
List<User> users = userRepository.findByIdLimit(startPosition, step);
Long endPosition = startPosition + step;
List<User> users = userRepository.findBtIdBetween(startPosition, endPosition);
if (users.isEmpty()) {
log.info("没有数据了. 结束了");
return;
......@@ -79,9 +80,9 @@ public class SyncHashController {
}
});
log.info("来一波,start:{},end:{}", startPosition, endPosition);
startPosition = users.get(users.size() - 1).getId() + 1;
log.info("来一波");
try {
Thread.sleep(250);
......
......@@ -50,4 +50,6 @@ public interface IUserRepository extends JpaRepository<User, Long>, JpaSpecifica
@Query(value = "select * from user where id >= ?1 limit ?2", nativeQuery = true)
List<User> findByIdLimit(Long id, Long limit);
List<User> findBtIdBetween(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