Skip to content

Commit

Permalink
for #4311,Fixed Derby data source related SQL LIMIT exception.
Browse files Browse the repository at this point in the history
  • Loading branch information
Maijh97 committed Nov 24, 2020
1 parent 0a983c8 commit 49188f1
Showing 1 changed file with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,15 @@
import org.apache.commons.lang3.StringUtils;
import org.springframework.context.annotation.Conditional;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Component;
import org.springframework.transaction.support.TransactionTemplate;
import org.springframework.util.Assert;

import javax.annotation.PostConstruct;
import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Collections;
Expand All @@ -72,6 +75,7 @@
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.stream.Collectors;

import static com.alibaba.nacos.config.server.service.repository.RowMapperManager.CONFIG_ADVANCE_INFO_ROW_MAPPER;
import static com.alibaba.nacos.config.server.service.repository.RowMapperManager.CONFIG_ALL_INFO_ROW_MAPPER;
Expand Down Expand Up @@ -1116,16 +1120,26 @@ public int configInfoTagCount() {

@Override
public List<String> getTenantIdList(int page, int pageSize) {
String sql = "SELECT tenant_id FROM config_info WHERE tenant_id != '' GROUP BY tenant_id LIMIT ?, ?";
PaginationHelper<String> helper = createPaginationHelper();

String sql = "SELECT tenant_id FROM config_info WHERE tenant_id != '' GROUP BY tenant_id LIMIT ?,?";

int from = (page - 1) * pageSize;
return databaseOperate.queryMany(sql, new Object[] {from, pageSize}, String.class);
Page<String> pageList = helper.fetchPageLimit(sql, new Object[] {from, pageSize}, page, pageSize,
(resultSet, i) -> resultSet.getString("tenant_id"));
return pageList.getPageItems();
}

@Override
public List<String> getGroupIdList(int page, int pageSize) {
String sql = "SELECT group_id FROM config_info WHERE tenant_id ='' GROUP BY group_id LIMIT ?, ?";
PaginationHelper<String> helper = createPaginationHelper();

String sql = "SELECT group_id FROM config_info WHERE tenant_id ='' GROUP BY group_id LIMIT ?,?";
int from = (page - 1) * pageSize;
return databaseOperate.queryMany(sql, new Object[] {from, pageSize}, String.class);

Page<String> pageList = helper.fetchPageLimit(sql, new Object[] {from, pageSize}, page, pageSize,
(resultSet, i) -> resultSet.getString("group_id"));
return pageList.getPageItems();
}

@Override
Expand Down

0 comments on commit 49188f1

Please sign in to comment.