修复DataJdbcSource.queryList会查total的BUG
This commit is contained in:
@@ -483,7 +483,8 @@ public class DataJdbcSource extends DataSqlSource<Connection> {
|
|||||||
final Map<Class, String> joinTabalis = node == null ? null : node.getJoinTabalis();
|
final Map<Class, String> joinTabalis = node == null ? null : node.getJoinTabalis();
|
||||||
final CharSequence join = node == null ? null : node.createSQLJoin(this, false, joinTabalis, new HashSet<>(), info);
|
final CharSequence join = node == null ? null : node.createSQLJoin(this, false, joinTabalis, new HashSet<>(), info);
|
||||||
final CharSequence where = node == null ? null : node.createSQLExpress(info, joinTabalis);
|
final CharSequence where = node == null ? null : node.createSQLExpress(info, joinTabalis);
|
||||||
if ("mysql".equals(this.readPool.getDbtype()) || "postgresql".equals(this.readPool.getDbtype())) {
|
final String dbtype = this.readPool.getDbtype();
|
||||||
|
if ("mysql".equals(dbtype) || "postgresql".equals(dbtype)) {
|
||||||
final String listsql = "SELECT " + info.getQueryColumns("a", selects) + " FROM " + info.getTable(node) + " a" + (join == null ? "" : join)
|
final String listsql = "SELECT " + info.getQueryColumns("a", selects) + " FROM " + info.getTable(node) + " a" + (join == null ? "" : join)
|
||||||
+ ((where == null || where.length() == 0) ? "" : (" WHERE " + where)) + createSQLOrderby(info, flipper) + (flipper == null || flipper.getLimit() < 1 ? "" : (" LIMIT " + flipper.getLimit() + " OFFSET " + flipper.getOffset()));
|
+ ((where == null || where.length() == 0) ? "" : (" WHERE " + where)) + createSQLOrderby(info, flipper) + (flipper == null || flipper.getLimit() < 1 ? "" : (" LIMIT " + flipper.getLimit() + " OFFSET " + flipper.getOffset()));
|
||||||
if (info.isLoggable(logger, Level.FINEST, listsql)) {
|
if (info.isLoggable(logger, Level.FINEST, listsql)) {
|
||||||
@@ -497,13 +498,17 @@ public class DataJdbcSource extends DataSqlSource<Connection> {
|
|||||||
set.close();
|
set.close();
|
||||||
ps.close();
|
ps.close();
|
||||||
long total = list.size();
|
long total = list.size();
|
||||||
final String countsql = "SELECT COUNT(*) FROM " + info.getTable(node) + " a" + (join == null ? "" : join)
|
if (needtotal) {
|
||||||
+ ((where == null || where.length() == 0) ? "" : (" WHERE " + where));
|
final String countsql = "SELECT COUNT(*) FROM " + info.getTable(node) + " a" + (join == null ? "" : join) + ((where == null || where.length() == 0) ? "" : (" WHERE " + where));
|
||||||
|
if (info.isLoggable(logger, Level.FINEST, countsql)) {
|
||||||
|
logger.finest(info.getType().getSimpleName() + " query countsql=" + countsql);
|
||||||
|
}
|
||||||
ps = conn.prepareStatement(countsql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
|
ps = conn.prepareStatement(countsql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
|
||||||
set = ps.executeQuery();
|
set = ps.executeQuery();
|
||||||
if (set.next()) total = set.getLong(1);
|
if (set.next()) total = set.getLong(1);
|
||||||
set.close();
|
set.close();
|
||||||
ps.close();
|
ps.close();
|
||||||
|
}
|
||||||
return CompletableFuture.completedFuture(new Sheet<>(total, list));
|
return CompletableFuture.completedFuture(new Sheet<>(total, list));
|
||||||
}
|
}
|
||||||
final String sql = "SELECT " + info.getQueryColumns("a", selects) + " FROM " + info.getTable(node) + " a" + (join == null ? "" : join)
|
final String sql = "SELECT " + info.getQueryColumns("a", selects) + " FROM " + info.getTable(node) + " a" + (join == null ? "" : join)
|
||||||
|
|||||||
Reference in New Issue
Block a user