优化DataJdbcSource
This commit is contained in:
@@ -1175,19 +1175,20 @@ public class DataJdbcSource extends DataSqlSource {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <T, N extends Number> CompletableFuture<Map<String, N>> getNumberMapDBAsync(EntityInfo<T> info, String[] tables, String sql, FilterFuncColumn... columns) {
|
||||
return supplyAsync(() -> getNumberMapDB(info, tables, sql, columns));
|
||||
protected <T, N extends Number> CompletableFuture<Map<String, N>> getNumberMapDBAsync(EntityInfo<T> info, String[] tables, String sql, FilterNode node, FilterFuncColumn... columns) {
|
||||
return supplyAsync(() -> getNumberMapDB(info, tables, sql, node, columns));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <T, N extends Number> Map<String, N> getNumberMapDB(EntityInfo<T> info, String[] tables, String sql, FilterFuncColumn... columns) {
|
||||
protected <T, N extends Number> Map<String, N> getNumberMapDB(EntityInfo<T> info, String[] tables, String sql, FilterNode node, FilterFuncColumn... columns) {
|
||||
Connection conn = null;
|
||||
final Map map = new HashMap<>();
|
||||
final long s = System.currentTimeMillis();
|
||||
Statement stmt = null;
|
||||
try {
|
||||
conn = readPool.pollConnection();
|
||||
//conn.setReadOnly(true);
|
||||
final Statement stmt = conn.createStatement();
|
||||
stmt = conn.createStatement();
|
||||
ResultSet set = stmt.executeQuery(sql);
|
||||
if (set.next()) {
|
||||
int index = 0;
|
||||
@@ -1207,6 +1208,7 @@ public class DataJdbcSource extends DataSqlSource {
|
||||
slowLog(s, sql);
|
||||
return map;
|
||||
} catch (SQLException e) {
|
||||
map.clear();
|
||||
if (isTableNotExist(info, e.getSQLState())) {
|
||||
if (info.getTableStrategy() == null) {
|
||||
String[] tableSqls = createTableSqls(info);
|
||||
@@ -1225,8 +1227,63 @@ public class DataJdbcSource extends DataSqlSource {
|
||||
} catch (SQLException e2) {
|
||||
}
|
||||
}
|
||||
return map;
|
||||
} else if (tables != null && tables.length == 1) {
|
||||
//只查一个不存在的分表
|
||||
return map;
|
||||
} else if (tables != null && tables.length > 1) {
|
||||
//多分表查询中一个或多个分表不存在
|
||||
String tableName = parseNotExistTableName(e);
|
||||
if (tableName == null) {
|
||||
throw new SourceException(e);
|
||||
}
|
||||
String[] oldTables = tables;
|
||||
List<String> notExistTables = checkNotExistTablesNoThrows(conn, tables, tableName);
|
||||
if (notExistTables.isEmpty()) {
|
||||
throw new SourceException(e);
|
||||
}
|
||||
for (String t : notExistTables) {
|
||||
tables = Utility.remove(tables, t);
|
||||
}
|
||||
if (logger.isLoggable(Level.FINE)) {
|
||||
logger.log(Level.FINE, "getNumberMap, old-tables: " + Arrays.toString(oldTables) + ", new-tables: " + Arrays.toString(tables));
|
||||
}
|
||||
if (tables.length == 0) { //分表全部不存在
|
||||
return map;
|
||||
}
|
||||
|
||||
//重新查询一次
|
||||
try {
|
||||
sql = getNumberMapSql(info, tables, node, columns);
|
||||
if (info.isLoggable(logger, Level.FINEST, sql)) {
|
||||
logger.finest(info.getType().getSimpleName() + " getNumberMap sql=" + sql);
|
||||
}
|
||||
if (stmt != null) {
|
||||
stmt.close();
|
||||
}
|
||||
stmt = conn.createStatement();
|
||||
ResultSet set = stmt.executeQuery(sql);
|
||||
if (set.next()) {
|
||||
int index = 0;
|
||||
for (FilterFuncColumn ffc : columns) {
|
||||
for (String col : ffc.cols()) {
|
||||
Object o = set.getObject(++index);
|
||||
Number rs = ffc.getDefvalue();
|
||||
if (o != null) {
|
||||
rs = (Number) o;
|
||||
}
|
||||
map.put(ffc.col(col), rs);
|
||||
}
|
||||
}
|
||||
}
|
||||
set.close();
|
||||
stmt.close();
|
||||
slowLog(s, sql);
|
||||
return map;
|
||||
} catch (SQLException se) {
|
||||
throw new SourceException(se);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
throw new SourceException(e);
|
||||
} finally {
|
||||
@@ -1237,18 +1294,19 @@ public class DataJdbcSource extends DataSqlSource {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <T> CompletableFuture<Number> getNumberResultDBAsync(EntityInfo<T> info, String[] tables, String sql, Number defVal, String column) {
|
||||
return supplyAsync(() -> getNumberResultDB(info, tables, sql, defVal, column));
|
||||
protected <T> CompletableFuture<Number> getNumberResultDBAsync(EntityInfo<T> info, String[] tables, String sql, FilterFunc func, Number defVal, String column, FilterNode node) {
|
||||
return supplyAsync(() -> getNumberResultDB(info, tables, sql, func, defVal, column, node));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <T> Number getNumberResultDB(EntityInfo<T> info, String[] tables, String sql, Number defVal, String column) {
|
||||
protected <T> Number getNumberResultDB(EntityInfo<T> info, String[] tables, String sql, FilterFunc func, Number defVal, String column, FilterNode node) {
|
||||
Connection conn = null;
|
||||
final long s = System.currentTimeMillis();
|
||||
Statement stmt = null;
|
||||
try {
|
||||
conn = readPool.pollConnection();
|
||||
//conn.setReadOnly(true);
|
||||
final Statement stmt = conn.createStatement();
|
||||
stmt = conn.createStatement();
|
||||
Number rs = defVal;
|
||||
ResultSet set = stmt.executeQuery(sql);
|
||||
if (set.next()) {
|
||||
@@ -1280,8 +1338,57 @@ public class DataJdbcSource extends DataSqlSource {
|
||||
} catch (SQLException e2) {
|
||||
}
|
||||
}
|
||||
return defVal;
|
||||
} else if (tables != null && tables.length == 1) {
|
||||
//只查一个不存在的分表
|
||||
return defVal;
|
||||
} else if (tables != null && tables.length > 1) {
|
||||
//多分表查询中一个或多个分表不存在
|
||||
String tableName = parseNotExistTableName(e);
|
||||
if (tableName == null) {
|
||||
throw new SourceException(e);
|
||||
}
|
||||
String[] oldTables = tables;
|
||||
List<String> notExistTables = checkNotExistTablesNoThrows(conn, tables, tableName);
|
||||
if (notExistTables.isEmpty()) {
|
||||
throw new SourceException(e);
|
||||
}
|
||||
for (String t : notExistTables) {
|
||||
tables = Utility.remove(tables, t);
|
||||
}
|
||||
if (logger.isLoggable(Level.FINE)) {
|
||||
logger.log(Level.FINE, "getNumberResult, old-tables: " + Arrays.toString(oldTables) + ", new-tables: " + Arrays.toString(tables));
|
||||
}
|
||||
if (tables.length == 0) { //分表全部不存在
|
||||
return defVal;
|
||||
}
|
||||
|
||||
//重新查询一次
|
||||
try {
|
||||
sql = getNumberResultSql(info, info.getType(), tables, func, defVal, column, node);
|
||||
if (info.isLoggable(logger, Level.FINEST, sql)) {
|
||||
logger.finest(info.getType().getSimpleName() + " getNumberResult sql=" + sql);
|
||||
}
|
||||
if (stmt != null) {
|
||||
stmt.close();
|
||||
}
|
||||
stmt = conn.createStatement();
|
||||
Number rs = defVal;
|
||||
ResultSet set = stmt.executeQuery(sql);
|
||||
if (set.next()) {
|
||||
Object o = set.getObject(1);
|
||||
if (o != null) {
|
||||
rs = (Number) o;
|
||||
}
|
||||
}
|
||||
set.close();
|
||||
stmt.close();
|
||||
slowLog(s, sql);
|
||||
return rs;
|
||||
} catch (SQLException se) {
|
||||
throw new SourceException(se);
|
||||
}
|
||||
}
|
||||
return defVal;
|
||||
}
|
||||
throw new SourceException(e);
|
||||
} finally {
|
||||
@@ -1292,19 +1399,20 @@ public class DataJdbcSource extends DataSqlSource {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <T, K extends Serializable, N extends Number> CompletableFuture<Map<K, N>> queryColumnMapDBAsync(EntityInfo<T> info, String[] tables, String sql, String keyColumn) {
|
||||
return supplyAsync(() -> queryColumnMapDB(info, tables, sql, keyColumn));
|
||||
protected <T, K extends Serializable, N extends Number> CompletableFuture<Map<K, N>> queryColumnMapDBAsync(EntityInfo<T> info, String[] tables, String sql, String keyColumn, FilterFunc func, String funcColumn, FilterNode node) {
|
||||
return supplyAsync(() -> queryColumnMapDB(info, tables, sql, keyColumn, func, funcColumn, node));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <T, K extends Serializable, N extends Number> Map<K, N> queryColumnMapDB(EntityInfo<T> info, String[] tables, String sql, String keyColumn) {
|
||||
protected <T, K extends Serializable, N extends Number> Map<K, N> queryColumnMapDB(EntityInfo<T> info, String[] tables, String sql, String keyColumn, FilterFunc func, String funcColumn, FilterNode node) {
|
||||
Connection conn = null;
|
||||
final long s = System.currentTimeMillis();
|
||||
Map<K, N> rs = new LinkedHashMap<>();
|
||||
Statement stmt = null;
|
||||
try {
|
||||
conn = readPool.pollConnection();
|
||||
//conn.setReadOnly(true);
|
||||
final Statement stmt = conn.createStatement();
|
||||
stmt = conn.createStatement();
|
||||
ResultSet set = stmt.executeQuery(sql);
|
||||
ResultSetMetaData rsd = set.getMetaData();
|
||||
boolean smallint = rsd == null ? false : rsd.getColumnType(1) == Types.SMALLINT;
|
||||
@@ -1316,6 +1424,7 @@ public class DataJdbcSource extends DataSqlSource {
|
||||
slowLog(s, sql);
|
||||
return rs;
|
||||
} catch (SQLException e) {
|
||||
rs.clear();
|
||||
if (isTableNotExist(info, e.getSQLState())) {
|
||||
if (info.getTableStrategy() == null) {
|
||||
String[] tableSqls = createTableSqls(info);
|
||||
@@ -1334,8 +1443,55 @@ public class DataJdbcSource extends DataSqlSource {
|
||||
} catch (SQLException e2) {
|
||||
}
|
||||
}
|
||||
return rs;
|
||||
} else if (tables != null && tables.length == 1) {
|
||||
//只查一个不存在的分表
|
||||
return rs;
|
||||
} else if (tables != null && tables.length > 1) {
|
||||
//多分表查询中一个或多个分表不存在
|
||||
String tableName = parseNotExistTableName(e);
|
||||
if (tableName == null) {
|
||||
throw new SourceException(e);
|
||||
}
|
||||
String[] oldTables = tables;
|
||||
List<String> notExistTables = checkNotExistTablesNoThrows(conn, tables, tableName);
|
||||
if (notExistTables.isEmpty()) {
|
||||
throw new SourceException(e);
|
||||
}
|
||||
for (String t : notExistTables) {
|
||||
tables = Utility.remove(tables, t);
|
||||
}
|
||||
if (logger.isLoggable(Level.FINE)) {
|
||||
logger.log(Level.FINE, "queryColumnMap, old-tables: " + Arrays.toString(oldTables) + ", new-tables: " + Arrays.toString(tables));
|
||||
}
|
||||
if (tables.length == 0) { //分表全部不存在
|
||||
return rs;
|
||||
}
|
||||
|
||||
//重新查询一次
|
||||
try {
|
||||
sql = queryColumnMapSql(info, tables, keyColumn, func, funcColumn, node);
|
||||
if (info.isLoggable(logger, Level.FINEST, sql)) {
|
||||
logger.finest(info.getType().getSimpleName() + " queryColumnMap sql=" + sql);
|
||||
}
|
||||
if (stmt != null) {
|
||||
stmt.close();
|
||||
}
|
||||
stmt = conn.createStatement();
|
||||
ResultSet set = stmt.executeQuery(sql);
|
||||
ResultSetMetaData rsd = set.getMetaData();
|
||||
boolean smallint = rsd == null ? false : rsd.getColumnType(1) == Types.SMALLINT;
|
||||
while (set.next()) {
|
||||
rs.put((K) (smallint ? set.getShort(1) : set.getObject(1)), (N) set.getObject(2));
|
||||
}
|
||||
set.close();
|
||||
stmt.close();
|
||||
slowLog(s, sql);
|
||||
return rs;
|
||||
} catch (SQLException se) {
|
||||
throw new SourceException(se);
|
||||
}
|
||||
}
|
||||
return rs;
|
||||
}
|
||||
throw new SourceException(e);
|
||||
} finally {
|
||||
@@ -1346,19 +1502,20 @@ public class DataJdbcSource extends DataSqlSource {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <T, K extends Serializable, N extends Number> CompletableFuture<Map<K[], N[]>> queryColumnMapDBAsync(EntityInfo<T> info, String[] tables, String sql, final ColumnNode[] funcNodes, final String[] groupByColumns) {
|
||||
return supplyAsync(() -> queryColumnMapDB(info, tables, sql, funcNodes, groupByColumns));
|
||||
protected <T, K extends Serializable, N extends Number> CompletableFuture<Map<K[], N[]>> queryColumnMapDBAsync(EntityInfo<T> info, String[] tables, String sql, final ColumnNode[] funcNodes, final String[] groupByColumns, final FilterNode node) {
|
||||
return supplyAsync(() -> queryColumnMapDB(info, tables, sql, funcNodes, groupByColumns, node));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <T, K extends Serializable, N extends Number> Map<K[], N[]> queryColumnMapDB(EntityInfo<T> info, String[] tables, String sql, final ColumnNode[] funcNodes, final String[] groupByColumns) {
|
||||
protected <T, K extends Serializable, N extends Number> Map<K[], N[]> queryColumnMapDB(EntityInfo<T> info, String[] tables, String sql, final ColumnNode[] funcNodes, final String[] groupByColumns, final FilterNode node) {
|
||||
Connection conn = null;
|
||||
Map rs = new LinkedHashMap<>();
|
||||
final long s = System.currentTimeMillis();
|
||||
Statement stmt = null;
|
||||
try {
|
||||
conn = readPool.pollConnection();
|
||||
//conn.setReadOnly(true);
|
||||
final Statement stmt = conn.createStatement();
|
||||
stmt = conn.createStatement();
|
||||
ResultSet set = stmt.executeQuery(sql);
|
||||
ResultSetMetaData rsd = set.getMetaData();
|
||||
boolean[] smallints = null;
|
||||
@@ -1385,6 +1542,7 @@ public class DataJdbcSource extends DataSqlSource {
|
||||
slowLog(s, sql);
|
||||
return rs;
|
||||
} catch (SQLException e) {
|
||||
rs.clear();
|
||||
if (isTableNotExist(info, e.getSQLState())) {
|
||||
if (info.getTableStrategy() == null) {
|
||||
String[] tableSqls = createTableSqls(info);
|
||||
@@ -1403,8 +1561,55 @@ public class DataJdbcSource extends DataSqlSource {
|
||||
} catch (SQLException e2) {
|
||||
}
|
||||
}
|
||||
return rs;
|
||||
} else if (tables != null && tables.length == 1) {
|
||||
//只查一个不存在的分表
|
||||
return rs;
|
||||
} else if (tables != null && tables.length > 1) {
|
||||
//多分表查询中一个或多个分表不存在
|
||||
String tableName = parseNotExistTableName(e);
|
||||
if (tableName == null) {
|
||||
throw new SourceException(e);
|
||||
}
|
||||
String[] oldTables = tables;
|
||||
List<String> notExistTables = checkNotExistTablesNoThrows(conn, tables, tableName);
|
||||
if (notExistTables.isEmpty()) {
|
||||
throw new SourceException(e);
|
||||
}
|
||||
for (String t : notExistTables) {
|
||||
tables = Utility.remove(tables, t);
|
||||
}
|
||||
if (logger.isLoggable(Level.FINE)) {
|
||||
logger.log(Level.FINE, "queryColumnMap, old-tables: " + Arrays.toString(oldTables) + ", new-tables: " + Arrays.toString(tables));
|
||||
}
|
||||
if (tables.length == 0) { //分表全部不存在
|
||||
return rs;
|
||||
}
|
||||
|
||||
//重新查询一次
|
||||
try {
|
||||
sql = queryColumnMapSql(info, tables, funcNodes, groupByColumns, node);
|
||||
if (info.isLoggable(logger, Level.FINEST, sql)) {
|
||||
logger.finest(info.getType().getSimpleName() + " queryColumnMap sql=" + sql);
|
||||
}
|
||||
if (stmt != null) {
|
||||
stmt.close();
|
||||
}
|
||||
stmt = conn.createStatement();
|
||||
ResultSet set = stmt.executeQuery(sql);
|
||||
ResultSetMetaData rsd = set.getMetaData();
|
||||
boolean smallint = rsd == null ? false : rsd.getColumnType(1) == Types.SMALLINT;
|
||||
while (set.next()) {
|
||||
rs.put((K) (smallint ? set.getShort(1) : set.getObject(1)), (N) set.getObject(2));
|
||||
}
|
||||
set.close();
|
||||
stmt.close();
|
||||
slowLog(s, sql);
|
||||
return rs;
|
||||
} catch (SQLException se) {
|
||||
throw new SourceException(se);
|
||||
}
|
||||
}
|
||||
return rs;
|
||||
}
|
||||
throw new SourceException(e);
|
||||
} finally {
|
||||
@@ -1415,18 +1620,19 @@ public class DataJdbcSource extends DataSqlSource {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <T> CompletableFuture<T> findDBAsync(EntityInfo<T> info, String[] tables, String sql, boolean onlypk, SelectColumn selects) {
|
||||
return supplyAsync(() -> findDB(info, tables, sql, onlypk, selects));
|
||||
protected <T> CompletableFuture<T> findDBAsync(EntityInfo<T> info, String[] tables, String sql, boolean onlypk, SelectColumn selects, Serializable pk, FilterNode node) {
|
||||
return supplyAsync(() -> findDB(info, tables, sql, onlypk, selects, pk, node));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <T> T findDB(EntityInfo<T> info, String[] tables, String sql, boolean onlypk, SelectColumn selects) {
|
||||
protected <T> T findDB(EntityInfo<T> info, String[] tables, String sql, boolean onlypk, SelectColumn selects, Serializable pk, FilterNode node) {
|
||||
Connection conn = null;
|
||||
final long s = System.currentTimeMillis();
|
||||
PreparedStatement ps = null;
|
||||
try {
|
||||
conn = readPool.pollConnection();
|
||||
//conn.setReadOnly(true);
|
||||
final PreparedStatement ps = conn.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
|
||||
ps = conn.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
|
||||
ps.setFetchSize(1);
|
||||
final DataResultSet set = createDataResultSet(info, ps.executeQuery());
|
||||
T rs = set.next() ? selects == null ? info.getFullEntityValue(set) : info.getEntityValue(selects, set) : null;
|
||||
@@ -1453,8 +1659,52 @@ public class DataJdbcSource extends DataSqlSource {
|
||||
} catch (SQLException e2) {
|
||||
}
|
||||
}
|
||||
return null;
|
||||
} else if (tables != null && tables.length == 1) {
|
||||
//只查一个不存在的分表
|
||||
return null;
|
||||
} else if (tables != null && tables.length > 1) {
|
||||
//多分表查询中一个或多个分表不存在
|
||||
String tableName = parseNotExistTableName(e);
|
||||
if (tableName == null) {
|
||||
throw new SourceException(e);
|
||||
}
|
||||
String[] oldTables = tables;
|
||||
List<String> notExistTables = checkNotExistTablesNoThrows(conn, tables, tableName);
|
||||
if (notExistTables.isEmpty()) {
|
||||
throw new SourceException(e);
|
||||
}
|
||||
for (String t : notExistTables) {
|
||||
tables = Utility.remove(tables, t);
|
||||
}
|
||||
if (logger.isLoggable(Level.FINE)) {
|
||||
logger.log(Level.FINE, "find, old-tables: " + Arrays.toString(oldTables) + ", new-tables: " + Arrays.toString(tables));
|
||||
}
|
||||
if (tables.length == 0) { //分表全部不存在
|
||||
return null;
|
||||
}
|
||||
|
||||
//重新查询一次
|
||||
try {
|
||||
sql = findSql(info, tables, selects, node);
|
||||
if (info.isLoggable(logger, Level.FINEST, sql)) {
|
||||
logger.finest(info.getType().getSimpleName() + " find sql=" + sql);
|
||||
}
|
||||
if (ps != null) {
|
||||
ps.close();
|
||||
}
|
||||
ps = conn.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
|
||||
ps.setFetchSize(1);
|
||||
final DataResultSet set = createDataResultSet(info, ps.executeQuery());
|
||||
T rs = set.next() ? selects == null ? info.getFullEntityValue(set) : info.getEntityValue(selects, set) : null;
|
||||
set.close();
|
||||
ps.close();
|
||||
slowLog(s, sql);
|
||||
return rs;
|
||||
} catch (SQLException se) {
|
||||
throw new SourceException(se);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
throw new SourceException(e);
|
||||
} finally {
|
||||
@@ -1465,19 +1715,20 @@ public class DataJdbcSource extends DataSqlSource {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <T> CompletableFuture<Serializable> findColumnDBAsync(EntityInfo<T> info, final String[] tables, String sql, boolean onlypk, String column, Serializable defValue) {
|
||||
return supplyAsync(() -> findColumnDB(info, tables, sql, onlypk, column, defValue));
|
||||
protected <T> CompletableFuture<Serializable> findColumnDBAsync(EntityInfo<T> info, final String[] tables, String sql, boolean onlypk, String column, Serializable defValue, Serializable pk, FilterNode node) {
|
||||
return supplyAsync(() -> findColumnDB(info, tables, sql, onlypk, column, defValue, pk, node));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <T> Serializable findColumnDB(EntityInfo<T> info, final String[] tables, String sql, boolean onlypk, String column, Serializable defValue) {
|
||||
protected <T> Serializable findColumnDB(EntityInfo<T> info, String[] tables, String sql, boolean onlypk, String column, Serializable defValue, Serializable pk, FilterNode node) {
|
||||
Connection conn = null;
|
||||
final long s = System.currentTimeMillis();
|
||||
PreparedStatement ps = null;
|
||||
final Attribute<T, Serializable> attr = info.getAttribute(column);
|
||||
try {
|
||||
conn = readPool.pollConnection();
|
||||
//conn.setReadOnly(true);
|
||||
final Attribute<T, Serializable> attr = info.getAttribute(column);
|
||||
final PreparedStatement ps = conn.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
|
||||
ps = conn.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
|
||||
ps.setFetchSize(1);
|
||||
final DataResultSet set = createDataResultSet(info, ps.executeQuery());
|
||||
Serializable val = defValue;
|
||||
@@ -1507,8 +1758,55 @@ public class DataJdbcSource extends DataSqlSource {
|
||||
} catch (SQLException e2) {
|
||||
}
|
||||
}
|
||||
return defValue;
|
||||
} else if (tables != null && tables.length == 1) {
|
||||
//只查一个不存在的分表
|
||||
return defValue;
|
||||
} else if (tables != null && tables.length > 1) {
|
||||
//多分表查询中一个或多个分表不存在
|
||||
String tableName = parseNotExistTableName(e);
|
||||
if (tableName == null) {
|
||||
throw new SourceException(e);
|
||||
}
|
||||
String[] oldTables = tables;
|
||||
List<String> notExistTables = checkNotExistTablesNoThrows(conn, tables, tableName);
|
||||
if (notExistTables.isEmpty()) {
|
||||
throw new SourceException(e);
|
||||
}
|
||||
for (String t : notExistTables) {
|
||||
tables = Utility.remove(tables, t);
|
||||
}
|
||||
if (logger.isLoggable(Level.FINE)) {
|
||||
logger.log(Level.FINE, "findColumn, old-tables: " + Arrays.toString(oldTables) + ", new-tables: " + Arrays.toString(tables));
|
||||
}
|
||||
if (tables.length == 0) { //分表全部不存在
|
||||
return defValue;
|
||||
}
|
||||
|
||||
//重新查询一次
|
||||
try {
|
||||
sql = findColumnSql(info, tables, column, defValue, node);
|
||||
if (info.isLoggable(logger, Level.FINEST, sql)) {
|
||||
logger.finest(info.getType().getSimpleName() + " findColumn sql=" + sql);
|
||||
}
|
||||
if (ps != null) {
|
||||
ps.close();
|
||||
}
|
||||
ps = conn.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
|
||||
ps.setFetchSize(1);
|
||||
final DataResultSet set = createDataResultSet(info, ps.executeQuery());
|
||||
Serializable val = defValue;
|
||||
if (set.next()) {
|
||||
val = info.getFieldValue(attr, set, 1);
|
||||
}
|
||||
set.close();
|
||||
ps.close();
|
||||
slowLog(s, sql);
|
||||
return val == null ? defValue : val;
|
||||
} catch (SQLException se) {
|
||||
throw new SourceException(se);
|
||||
}
|
||||
}
|
||||
return defValue;
|
||||
}
|
||||
throw new SourceException(e);
|
||||
} finally {
|
||||
@@ -1519,18 +1817,19 @@ public class DataJdbcSource extends DataSqlSource {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <T> CompletableFuture<Boolean> existsDBAsync(EntityInfo<T> info, final String[] tables, String sql, boolean onlypk) {
|
||||
return supplyAsync(() -> existsDB(info, tables, sql, onlypk));
|
||||
protected <T> CompletableFuture<Boolean> existsDBAsync(EntityInfo<T> info, final String[] tables, String sql, boolean onlypk, Serializable pk, FilterNode node) {
|
||||
return supplyAsync(() -> existsDB(info, tables, sql, onlypk, pk, node));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <T> boolean existsDB(EntityInfo<T> info, final String[] tables, String sql, boolean onlypk) {
|
||||
protected <T> boolean existsDB(EntityInfo<T> info, String[] tables, String sql, boolean onlypk, Serializable pk, FilterNode node) {
|
||||
Connection conn = null;
|
||||
final long s = System.currentTimeMillis();
|
||||
PreparedStatement ps = null;
|
||||
try {
|
||||
conn = readPool.pollConnection();
|
||||
//conn.setReadOnly(true);
|
||||
final PreparedStatement ps = conn.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
|
||||
ps = conn.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
|
||||
final ResultSet set = ps.executeQuery();
|
||||
boolean rs = set.next() ? (set.getInt(1) > 0) : false;
|
||||
set.close();
|
||||
@@ -1559,8 +1858,54 @@ public class DataJdbcSource extends DataSqlSource {
|
||||
} catch (SQLException e2) {
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} else if (tables != null && tables.length == 1) {
|
||||
//只查一个不存在的分表
|
||||
return false;
|
||||
} else if (tables != null && tables.length > 1) {
|
||||
//多分表查询中一个或多个分表不存在
|
||||
String tableName = parseNotExistTableName(e);
|
||||
if (tableName == null) {
|
||||
throw new SourceException(e);
|
||||
}
|
||||
String[] oldTables = tables;
|
||||
List<String> notExistTables = checkNotExistTablesNoThrows(conn, tables, tableName);
|
||||
if (notExistTables.isEmpty()) {
|
||||
throw new SourceException(e);
|
||||
}
|
||||
for (String t : notExistTables) {
|
||||
tables = Utility.remove(tables, t);
|
||||
}
|
||||
if (logger.isLoggable(Level.FINE)) {
|
||||
logger.log(Level.FINE, "exists, old-tables: " + Arrays.toString(oldTables) + ", new-tables: " + Arrays.toString(tables));
|
||||
}
|
||||
if (tables.length == 0) { //分表全部不存在
|
||||
return false;
|
||||
}
|
||||
|
||||
//重新查询一次
|
||||
try {
|
||||
sql = existsSql(info, tables, node);
|
||||
if (info.isLoggable(logger, Level.FINEST, sql)) {
|
||||
logger.finest(info.getType().getSimpleName() + " exists sql=" + sql);
|
||||
}
|
||||
if (ps != null) {
|
||||
ps.close();
|
||||
}
|
||||
ps = conn.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
|
||||
final ResultSet set = ps.executeQuery();
|
||||
boolean rs = set.next() ? (set.getInt(1) > 0) : false;
|
||||
set.close();
|
||||
ps.close();
|
||||
if (info.isLoggable(logger, Level.FINEST, sql)) {
|
||||
logger.finest(info.getType().getSimpleName() + " exists (" + rs + ") sql=" + sql);
|
||||
}
|
||||
slowLog(s, sql);
|
||||
return rs;
|
||||
} catch (SQLException se) {
|
||||
throw new SourceException(se);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
throw new SourceException(e);
|
||||
} finally {
|
||||
@@ -1631,7 +1976,7 @@ public class DataJdbcSource extends DataSqlSource {
|
||||
tables = Utility.remove(tables, t);
|
||||
}
|
||||
if (logger.isLoggable(Level.FINE)) {
|
||||
logger.log(Level.FINE, "query sheet, old-tables: " + Arrays.toString(oldTables) + ", new-tables: " + Arrays.toString(tables));
|
||||
logger.log(Level.FINE, "querySheet, old-tables: " + Arrays.toString(oldTables) + ", new-tables: " + Arrays.toString(tables));
|
||||
}
|
||||
if (tables.length == 0) { //分表全部不存在
|
||||
return new Sheet<>(0, new ArrayList());
|
||||
@@ -1764,7 +2109,7 @@ public class DataJdbcSource extends DataSqlSource {
|
||||
}
|
||||
countSql = countSubSql;
|
||||
if (readCache && info.isLoggable(logger, Level.FINEST, countSql)) {
|
||||
logger.finest(info.getType().getSimpleName() + " query countsql=" + countSql);
|
||||
logger.finest(info.getType().getSimpleName() + " querySheet countsql=" + countSql);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,37 +147,37 @@ public class DataMemorySource extends DataSqlSource implements SearchSource {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <T, N extends Number> Map<String, N> getNumberMapDB(EntityInfo<T> info, String[] tables, String sql, FilterFuncColumn... columns) {
|
||||
protected <T, N extends Number> Map<String, N> getNumberMapDB(EntityInfo<T> info, String[] tables, String sql, FilterNode node, FilterFuncColumn... columns) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <T> Number getNumberResultDB(EntityInfo<T> info, String[] tables, String sql, Number defVal, String column) {
|
||||
protected <T> Number getNumberResultDB(EntityInfo<T> info, String[] tables, String sql, FilterFunc func, Number defVal, String column, final FilterNode node) {
|
||||
return defVal;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <T, K extends Serializable, N extends Number> Map<K, N> queryColumnMapDB(EntityInfo<T> info, String[] tables, String sql, String keyColumn) {
|
||||
protected <T, K extends Serializable, N extends Number> Map<K, N> queryColumnMapDB(EntityInfo<T> info, String[] tables, String sql, String keyColumn, FilterFunc func, String funcColumn, FilterNode node) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <T, K extends Serializable, N extends Number> Map<K[], N[]> queryColumnMapDB(final EntityInfo<T> info, String[] tables, final String sql, final ColumnNode[] funcNodes, final String[] groupByColumns) {
|
||||
protected <T, K extends Serializable, N extends Number> Map<K[], N[]> queryColumnMapDB(final EntityInfo<T> info, String[] tables, final String sql, final ColumnNode[] funcNodes, final String[] groupByColumns, FilterNode node) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <T> T findDB(EntityInfo<T> info, String[] tables, String sql, boolean onlypk, SelectColumn selects) {
|
||||
protected <T> T findDB(EntityInfo<T> info, String[] tables, String sql, boolean onlypk, SelectColumn selects, Serializable pk, FilterNode node) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <T> Serializable findColumnDB(EntityInfo<T> info, final String[] tables, String sql, boolean onlypk, String column, Serializable defValue) {
|
||||
protected <T> Serializable findColumnDB(EntityInfo<T> info, final String[] tables, String sql, boolean onlypk, String column, Serializable defValue, Serializable pk, FilterNode node) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <T> boolean existsDB(EntityInfo<T> info, final String[] tables, String sql, boolean onlypk) {
|
||||
protected <T> boolean existsDB(EntityInfo<T> info, final String[] tables, String sql, boolean onlypk, Serializable pk, FilterNode node) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -217,37 +217,37 @@ public class DataMemorySource extends DataSqlSource implements SearchSource {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <T, N extends Number> CompletableFuture<Map<String, N>> getNumberMapDBAsync(EntityInfo<T> info, String[] tables, String sql, FilterFuncColumn... columns) {
|
||||
protected <T, N extends Number> CompletableFuture<Map<String, N>> getNumberMapDBAsync(EntityInfo<T> info, String[] tables, String sql, FilterNode node, FilterFuncColumn... columns) {
|
||||
return CompletableFuture.completedFuture(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <T> CompletableFuture<Number> getNumberResultDBAsync(EntityInfo<T> info, String[] tables, String sql, Number defVal, String column) {
|
||||
protected <T> CompletableFuture<Number> getNumberResultDBAsync(EntityInfo<T> info, String[] tables, String sql, FilterFunc func, Number defVal, String column, FilterNode node) {
|
||||
return CompletableFuture.completedFuture(defVal);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <T, K extends Serializable, N extends Number> CompletableFuture<Map<K, N>> queryColumnMapDBAsync(EntityInfo<T> info, String[] tables, String sql, String keyColumn) {
|
||||
protected <T, K extends Serializable, N extends Number> CompletableFuture<Map<K, N>> queryColumnMapDBAsync(EntityInfo<T> info, String[] tables, String sql, String keyColumn, FilterFunc func, String funcColumn, FilterNode node) {
|
||||
return CompletableFuture.completedFuture(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <T, K extends Serializable, N extends Number> CompletableFuture<Map<K[], N[]>> queryColumnMapDBAsync(final EntityInfo<T> info, String[] tables, final String sql, final ColumnNode[] funcNodes, final String[] groupByColumns) {
|
||||
protected <T, K extends Serializable, N extends Number> CompletableFuture<Map<K[], N[]>> queryColumnMapDBAsync(final EntityInfo<T> info, String[] tables, final String sql, final ColumnNode[] funcNodes, final String[] groupByColumns, FilterNode node) {
|
||||
return CompletableFuture.completedFuture(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <T> CompletableFuture<T> findDBAsync(EntityInfo<T> info, String[] tables, String sql, boolean onlypk, SelectColumn selects) {
|
||||
protected <T> CompletableFuture<T> findDBAsync(EntityInfo<T> info, String[] tables, String sql, boolean onlypk, SelectColumn selects, Serializable pk, FilterNode node) {
|
||||
return CompletableFuture.completedFuture(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <T> CompletableFuture<Serializable> findColumnDBAsync(EntityInfo<T> info, final String[] tables, String sql, boolean onlypk, String column, Serializable defValue) {
|
||||
protected <T> CompletableFuture<Serializable> findColumnDBAsync(EntityInfo<T> info, final String[] tables, String sql, boolean onlypk, String column, Serializable defValue, Serializable pk, FilterNode node) {
|
||||
return CompletableFuture.completedFuture(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <T> CompletableFuture<Boolean> existsDBAsync(EntityInfo<T> info, final String[] tables, String sql, boolean onlypk) {
|
||||
protected <T> CompletableFuture<Boolean> existsDBAsync(EntityInfo<T> info, final String[] tables, String sql, boolean onlypk, Serializable pk, FilterNode node) {
|
||||
return CompletableFuture.completedFuture(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -682,25 +682,25 @@ public abstract class DataSqlSource extends AbstractDataSource implements Functi
|
||||
protected abstract <T> CompletableFuture<Integer> updateColumnDBAsync(final EntityInfo<T> info, Flipper flipper, final UpdateSqlInfo sql);
|
||||
|
||||
//查询Number Map数据
|
||||
protected abstract <T, N extends Number> CompletableFuture<Map<String, N>> getNumberMapDBAsync(final EntityInfo<T> info, String[] tables, final String sql, final FilterFuncColumn... columns);
|
||||
protected abstract <T, N extends Number> CompletableFuture<Map<String, N>> getNumberMapDBAsync(final EntityInfo<T> info, String[] tables, final String sql, final FilterNode node, final FilterFuncColumn... columns);
|
||||
|
||||
//查询Number数据
|
||||
protected abstract <T> CompletableFuture<Number> getNumberResultDBAsync(final EntityInfo<T> info, String[] tables, final String sql, final Number defVal, final String column);
|
||||
protected abstract <T> CompletableFuture<Number> getNumberResultDBAsync(final EntityInfo<T> info, String[] tables, final String sql, final FilterFunc func, final Number defVal, final String column, final FilterNode node);
|
||||
|
||||
//查询Map数据
|
||||
protected abstract <T, K extends Serializable, N extends Number> CompletableFuture<Map<K, N>> queryColumnMapDBAsync(final EntityInfo<T> info, String[] tables, final String sql, final String keyColumn);
|
||||
protected abstract <T, K extends Serializable, N extends Number> CompletableFuture<Map<K, N>> queryColumnMapDBAsync(final EntityInfo<T> info, String[] tables, final String sql, final String keyColumn, final FilterFunc func, final String funcColumn, FilterNode node);
|
||||
|
||||
//查询Map数据
|
||||
protected abstract <T, K extends Serializable, N extends Number> CompletableFuture<Map<K[], N[]>> queryColumnMapDBAsync(final EntityInfo<T> info, String[] tables, final String sql, final ColumnNode[] funcNodes, final String[] groupByColumns);
|
||||
protected abstract <T, K extends Serializable, N extends Number> CompletableFuture<Map<K[], N[]>> queryColumnMapDBAsync(final EntityInfo<T> info, String[] tables, final String sql, final ColumnNode[] funcNodes, final String[] groupByColumns, final FilterNode node);
|
||||
|
||||
//查询单条记录
|
||||
protected abstract <T> CompletableFuture<T> findDBAsync(final EntityInfo<T> info, String[] tables, final String sql, final boolean onlypk, final SelectColumn selects);
|
||||
protected abstract <T> CompletableFuture<T> findDBAsync(final EntityInfo<T> info, String[] tables, final String sql, final boolean onlypk, final SelectColumn selects, final Serializable pk, final FilterNode node);
|
||||
|
||||
//查询单条记录的单个字段
|
||||
protected abstract <T> CompletableFuture<Serializable> findColumnDBAsync(final EntityInfo<T> info, String[] tables, final String sql, final boolean onlypk, final String column, final Serializable defValue);
|
||||
protected abstract <T> CompletableFuture<Serializable> findColumnDBAsync(final EntityInfo<T> info, String[] tables, final String sql, final boolean onlypk, final String column, final Serializable defValue, final Serializable pk, final FilterNode node);
|
||||
|
||||
//判断记录是否存在
|
||||
protected abstract <T> CompletableFuture<Boolean> existsDBAsync(final EntityInfo<T> info, final String[] tables, final String sql, final boolean onlypk);
|
||||
protected abstract <T> CompletableFuture<Boolean> existsDBAsync(final EntityInfo<T> info, final String[] tables, final String sql, final boolean onlypk, final Serializable pk, final FilterNode node);
|
||||
|
||||
//查询一页数据
|
||||
protected abstract <T> CompletableFuture<Sheet<T>> querySheetDBAsync(final EntityInfo<T> info, final boolean readcache, final boolean needtotal, final boolean distinct, final SelectColumn selects, final Flipper flipper, final FilterNode node);
|
||||
@@ -736,38 +736,38 @@ public abstract class DataSqlSource extends AbstractDataSource implements Functi
|
||||
}
|
||||
|
||||
//查询Number Map数据
|
||||
protected <T, N extends Number> Map<String, N> getNumberMapDB(final EntityInfo<T> info, String[] tables, final String sql, final FilterFuncColumn... columns) {
|
||||
return (Map) getNumberMapDBAsync(info, tables, sql, columns).join();
|
||||
protected <T, N extends Number> Map<String, N> getNumberMapDB(final EntityInfo<T> info, String[] tables, final String sql, final FilterNode node, final FilterFuncColumn... columns) {
|
||||
return (Map) getNumberMapDBAsync(info, tables, sql, node, columns).join();
|
||||
}
|
||||
|
||||
//查询Number数据
|
||||
protected <T> Number getNumberResultDB(final EntityInfo<T> info, String[] tables, final String sql, final Number defVal, final String column) {
|
||||
return getNumberResultDBAsync(info, tables, sql, defVal, column).join();
|
||||
protected <T> Number getNumberResultDB(final EntityInfo<T> info, String[] tables, final String sql, final FilterFunc func, final Number defVal, final String column, final FilterNode node) {
|
||||
return getNumberResultDBAsync(info, tables, sql, func, defVal, column, node).join();
|
||||
}
|
||||
|
||||
//查询Map数据
|
||||
protected <T, K extends Serializable, N extends Number> Map<K, N> queryColumnMapDB(final EntityInfo<T> info, String[] tables, final String sql, final String keyColumn) {
|
||||
return (Map) queryColumnMapDBAsync(info, tables, sql, keyColumn).join();
|
||||
protected <T, K extends Serializable, N extends Number> Map<K, N> queryColumnMapDB(final EntityInfo<T> info, String[] tables, final String sql, final String keyColumn, final FilterFunc func, final String funcColumn, FilterNode node) {
|
||||
return (Map) queryColumnMapDBAsync(info, tables, sql, keyColumn, func, funcColumn, node).join();
|
||||
}
|
||||
|
||||
//查询Map数据
|
||||
protected <T, K extends Serializable, N extends Number> Map<K[], N[]> queryColumnMapDB(final EntityInfo<T> info, String[] tables, final String sql, final ColumnNode[] funcNodes, final String[] groupByColumns) {
|
||||
return (Map) queryColumnMapDBAsync(info, tables, sql, funcNodes, groupByColumns).join();
|
||||
protected <T, K extends Serializable, N extends Number> Map<K[], N[]> queryColumnMapDB(final EntityInfo<T> info, String[] tables, final String sql, final ColumnNode[] funcNodes, final String[] groupByColumns, final FilterNode node) {
|
||||
return (Map) queryColumnMapDBAsync(info, tables, sql, funcNodes, groupByColumns, node).join();
|
||||
}
|
||||
|
||||
//查询单条记录
|
||||
protected <T> T findDB(final EntityInfo<T> info, String[] tables, final String sql, final boolean onlypk, final SelectColumn selects) {
|
||||
return findDBAsync(info, tables, sql, onlypk, selects).join();
|
||||
protected <T> T findDB(final EntityInfo<T> info, String[] tables, final String sql, final boolean onlypk, final SelectColumn selects, final Serializable pk, final FilterNode node) {
|
||||
return findDBAsync(info, tables, sql, onlypk, selects, pk, node).join();
|
||||
}
|
||||
|
||||
//查询单条记录的单个字段
|
||||
protected <T> Serializable findColumnDB(final EntityInfo<T> info, String[] tables, final String sql, final boolean onlypk, final String column, final Serializable defValue) {
|
||||
return findColumnDBAsync(info, tables, sql, onlypk, column, defValue).join();
|
||||
protected <T> Serializable findColumnDB(final EntityInfo<T> info, String[] tables, final String sql, final boolean onlypk, final String column, final Serializable defValue, final Serializable pk, final FilterNode node) {
|
||||
return findColumnDBAsync(info, tables, sql, onlypk, column, defValue, pk, node).join();
|
||||
}
|
||||
|
||||
//判断记录是否存在
|
||||
protected <T> boolean existsDB(final EntityInfo<T> info, final String[] tables, final String sql, final boolean onlypk) {
|
||||
return existsDBAsync(info, tables, sql, onlypk).join();
|
||||
protected <T> boolean existsDB(final EntityInfo<T> info, final String[] tables, final String sql, final boolean onlypk, final Serializable pk, final FilterNode node) {
|
||||
return existsDBAsync(info, tables, sql, onlypk, pk, node).join();
|
||||
}
|
||||
|
||||
//查询一页数据
|
||||
@@ -2080,9 +2080,9 @@ public abstract class DataSqlSource extends AbstractDataSource implements Functi
|
||||
logger.finest(info.getType().getSimpleName() + " getNumberMap sql=" + sql);
|
||||
}
|
||||
if (isAsync()) {
|
||||
return (Map) getNumberMapDBAsync(info, tables, sql, columns).join();
|
||||
return (Map) getNumberMapDBAsync(info, tables, sql, node, columns).join();
|
||||
} else {
|
||||
return getNumberMapDB(info, tables, sql, columns);
|
||||
return getNumberMapDB(info, tables, sql, node, columns);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2107,9 +2107,9 @@ public abstract class DataSqlSource extends AbstractDataSource implements Functi
|
||||
logger.finest(info.getType().getSimpleName() + " getNumberMap sql=" + sql);
|
||||
}
|
||||
if (isAsync()) {
|
||||
return getNumberMapDBAsync(info, tables, sql, columns);
|
||||
return getNumberMapDBAsync(info, tables, sql, node, columns);
|
||||
} else {
|
||||
return supplyAsync(() -> getNumberMapDB(info, tables, sql, columns));
|
||||
return supplyAsync(() -> getNumberMapDB(info, tables, sql, node, columns));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2171,9 +2171,9 @@ public abstract class DataSqlSource extends AbstractDataSource implements Functi
|
||||
logger.finest(info.getType().getSimpleName() + " getNumberResult sql=" + sql);
|
||||
}
|
||||
if (isAsync()) {
|
||||
return getNumberResultDBAsync(info, tables, sql, defVal, column).join();
|
||||
return getNumberResultDBAsync(info, tables, sql, func, defVal, column, node).join();
|
||||
} else {
|
||||
return getNumberResultDB(info, tables, sql, defVal, column);
|
||||
return getNumberResultDB(info, tables, sql, func, defVal, column, node);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2192,9 +2192,9 @@ public abstract class DataSqlSource extends AbstractDataSource implements Functi
|
||||
logger.finest(info.getType().getSimpleName() + " getNumberResult sql=" + sql);
|
||||
}
|
||||
if (isAsync()) {
|
||||
return getNumberResultDBAsync(info, tables, sql, defVal, column);
|
||||
return getNumberResultDBAsync(info, tables, sql, func, defVal, column, node);
|
||||
} else {
|
||||
return supplyAsync(() -> getNumberResultDB(info, tables, sql, defVal, column));
|
||||
return supplyAsync(() -> getNumberResultDB(info, tables, sql, func, defVal, column, node));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2240,9 +2240,9 @@ public abstract class DataSqlSource extends AbstractDataSource implements Functi
|
||||
logger.finest(info.getType().getSimpleName() + " queryColumnMap sql=" + sql);
|
||||
}
|
||||
if (isAsync()) {
|
||||
return (Map) queryColumnMapDBAsync(info, tables, sql, keyColumn).join();
|
||||
return (Map) queryColumnMapDBAsync(info, tables, sql, keyColumn, func, funcColumn, node).join();
|
||||
} else {
|
||||
return queryColumnMapDB(info, tables, sql, keyColumn);
|
||||
return queryColumnMapDB(info, tables, sql, keyColumn, func, funcColumn, node);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2261,9 +2261,9 @@ public abstract class DataSqlSource extends AbstractDataSource implements Functi
|
||||
logger.finest(info.getType().getSimpleName() + " queryColumnMap sql=" + sql);
|
||||
}
|
||||
if (isAsync()) {
|
||||
return queryColumnMapDBAsync(info, tables, sql, keyColumn);
|
||||
return queryColumnMapDBAsync(info, tables, sql, keyColumn, func, funcColumn, node);
|
||||
} else {
|
||||
return supplyAsync(() -> queryColumnMapDB(info, tables, sql, keyColumn));
|
||||
return supplyAsync(() -> queryColumnMapDB(info, tables, sql, keyColumn, func, funcColumn, node));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2339,9 +2339,9 @@ public abstract class DataSqlSource extends AbstractDataSource implements Functi
|
||||
logger.finest(info.getType().getSimpleName() + " queryColumnMap sql=" + sql);
|
||||
}
|
||||
if (isAsync()) {
|
||||
return (Map) queryColumnMapDBAsync(info, tables, sql, funcNodes, groupByColumns).join();
|
||||
return (Map) queryColumnMapDBAsync(info, tables, sql, funcNodes, groupByColumns, node).join();
|
||||
} else {
|
||||
return queryColumnMapDB(info, tables, sql, funcNodes, groupByColumns);
|
||||
return queryColumnMapDB(info, tables, sql, funcNodes, groupByColumns, node);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2360,9 +2360,9 @@ public abstract class DataSqlSource extends AbstractDataSource implements Functi
|
||||
logger.finest(info.getType().getSimpleName() + " queryColumnMap sql=" + sql);
|
||||
}
|
||||
if (isAsync()) {
|
||||
return queryColumnMapDBAsync(info, tables, sql, funcNodes, groupByColumns);
|
||||
return queryColumnMapDBAsync(info, tables, sql, funcNodes, groupByColumns, node);
|
||||
} else {
|
||||
return supplyAsync(() -> queryColumnMapDB(info, tables, sql, funcNodes, groupByColumns));
|
||||
return supplyAsync(() -> queryColumnMapDB(info, tables, sql, funcNodes, groupByColumns, node));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2515,9 +2515,9 @@ public abstract class DataSqlSource extends AbstractDataSource implements Functi
|
||||
logger.finest(info.getType().getSimpleName() + " find sql=" + sql);
|
||||
}
|
||||
if (isAsync()) {
|
||||
return findDBAsync(info, new String[]{table}, sql, true, selects).join();
|
||||
return findDBAsync(info, new String[]{table}, sql, true, selects, pk, null).join();
|
||||
} else {
|
||||
return findDB(info, new String[]{table}, sql, true, selects);
|
||||
return findDB(info, new String[]{table}, sql, true, selects, pk, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2537,9 +2537,9 @@ public abstract class DataSqlSource extends AbstractDataSource implements Functi
|
||||
logger.finest(info.getType().getSimpleName() + " find sql=" + sql);
|
||||
}
|
||||
if (isAsync()) {
|
||||
return findDBAsync(info, new String[]{table}, sql, true, selects);
|
||||
return findDBAsync(info, new String[]{table}, sql, true, selects, pk, null);
|
||||
} else {
|
||||
return supplyAsync(() -> findDB(info, new String[]{table}, sql, true, selects));
|
||||
return supplyAsync(() -> findDB(info, new String[]{table}, sql, true, selects, pk, null));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2565,9 +2565,9 @@ public abstract class DataSqlSource extends AbstractDataSource implements Functi
|
||||
logger.finest(info.getType().getSimpleName() + " find sql=" + sql);
|
||||
}
|
||||
if (isAsync()) {
|
||||
return findDBAsync(info, tables, sql, false, selects).join();
|
||||
return findDBAsync(info, tables, sql, false, selects, null, node).join();
|
||||
} else {
|
||||
return findDB(info, tables, sql, false, selects);
|
||||
return findDB(info, tables, sql, false, selects, null, node);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2584,9 +2584,9 @@ public abstract class DataSqlSource extends AbstractDataSource implements Functi
|
||||
logger.finest(info.getType().getSimpleName() + " find sql=" + sql);
|
||||
}
|
||||
if (isAsync()) {
|
||||
return findDBAsync(info, tables, sql, false, selects);
|
||||
return findDBAsync(info, tables, sql, false, selects, null, node);
|
||||
} else {
|
||||
return supplyAsync(() -> findDB(info, tables, sql, false, selects));
|
||||
return supplyAsync(() -> findDB(info, tables, sql, false, selects, null, node));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2636,9 +2636,9 @@ public abstract class DataSqlSource extends AbstractDataSource implements Functi
|
||||
logger.finest(info.getType().getSimpleName() + " findColumn sql=" + sql);
|
||||
}
|
||||
if (isAsync()) {
|
||||
return findColumnDBAsync(info, new String[]{table}, sql, true, column, defValue).join();
|
||||
return findColumnDBAsync(info, new String[]{table}, sql, true, column, defValue, pk, null).join();
|
||||
} else {
|
||||
return findColumnDB(info, new String[]{table}, sql, true, column, defValue);
|
||||
return findColumnDB(info, new String[]{table}, sql, true, column, defValue, pk, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2658,9 +2658,9 @@ public abstract class DataSqlSource extends AbstractDataSource implements Functi
|
||||
logger.finest(info.getType().getSimpleName() + " findColumn sql=" + sql);
|
||||
}
|
||||
if (isAsync()) {
|
||||
return findColumnDBAsync(info, new String[]{table}, sql, true, column, defValue);
|
||||
return findColumnDBAsync(info, new String[]{table}, sql, true, column, defValue, pk, null);
|
||||
} else {
|
||||
return supplyAsync(() -> findColumnDB(info, new String[]{table}, sql, true, column, defValue));
|
||||
return supplyAsync(() -> findColumnDB(info, new String[]{table}, sql, true, column, defValue, pk, null));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2684,9 +2684,9 @@ public abstract class DataSqlSource extends AbstractDataSource implements Functi
|
||||
logger.finest(info.getType().getSimpleName() + " findColumn sql=" + sql);
|
||||
}
|
||||
if (isAsync()) {
|
||||
return findColumnDBAsync(info, tables, sql, false, column, defValue).join();
|
||||
return findColumnDBAsync(info, tables, sql, false, column, defValue, null, node).join();
|
||||
} else {
|
||||
return findColumnDB(info, tables, sql, false, column, defValue);
|
||||
return findColumnDB(info, tables, sql, false, column, defValue, null, node);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2706,9 +2706,9 @@ public abstract class DataSqlSource extends AbstractDataSource implements Functi
|
||||
logger.finest(info.getType().getSimpleName() + " findColumn sql=" + sql);
|
||||
}
|
||||
if (isAsync()) {
|
||||
return findColumnDBAsync(info, tables, sql, false, column, defValue);
|
||||
return findColumnDBAsync(info, tables, sql, false, column, defValue, null, node);
|
||||
} else {
|
||||
return supplyAsync(() -> findColumnDB(info, tables, sql, false, column, defValue));
|
||||
return supplyAsync(() -> findColumnDB(info, tables, sql, false, column, defValue, null, node));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2763,9 +2763,9 @@ public abstract class DataSqlSource extends AbstractDataSource implements Functi
|
||||
logger.finest(info.getType().getSimpleName() + " exists sql=" + sql);
|
||||
}
|
||||
if (isAsync()) {
|
||||
return existsDBAsync(info, new String[]{table}, sql, true).join();
|
||||
return existsDBAsync(info, new String[]{table}, sql, true, pk, null).join();
|
||||
} else {
|
||||
return existsDB(info, new String[]{table}, sql, true);
|
||||
return existsDB(info, new String[]{table}, sql, true, pk, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2785,9 +2785,9 @@ public abstract class DataSqlSource extends AbstractDataSource implements Functi
|
||||
logger.finest(info.getType().getSimpleName() + " exists sql=" + sql);
|
||||
}
|
||||
if (isAsync()) {
|
||||
return existsDBAsync(info, new String[]{table}, sql, true);
|
||||
return existsDBAsync(info, new String[]{table}, sql, true, pk, null);
|
||||
} else {
|
||||
return supplyAsync(() -> existsDB(info, new String[]{table}, sql, true));
|
||||
return supplyAsync(() -> existsDB(info, new String[]{table}, sql, true, pk, null));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2811,9 +2811,9 @@ public abstract class DataSqlSource extends AbstractDataSource implements Functi
|
||||
logger.finest(info.getType().getSimpleName() + " exists sql=" + sql);
|
||||
}
|
||||
if (isAsync()) {
|
||||
return existsDBAsync(info, tables, sql, false).join();
|
||||
return existsDBAsync(info, tables, sql, false, null, node).join();
|
||||
} else {
|
||||
return existsDB(info, tables, sql, false);
|
||||
return existsDB(info, tables, sql, false, null, node);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2834,9 +2834,9 @@ public abstract class DataSqlSource extends AbstractDataSource implements Functi
|
||||
logger.finest(info.getType().getSimpleName() + " exists sql=" + sql);
|
||||
}
|
||||
if (isAsync()) {
|
||||
return existsDBAsync(info, tables, sql, false);
|
||||
return existsDBAsync(info, tables, sql, false, null, node);
|
||||
} else {
|
||||
return supplyAsync(() -> existsDB(info, tables, sql, false));
|
||||
return supplyAsync(() -> existsDB(info, tables, sql, false, null, node));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user