DataSource优化
This commit is contained in:
@@ -2490,8 +2490,8 @@ public class DataJdbcSource extends AbstractDataSqlSource {
|
||||
* @return 结果数组
|
||||
*/
|
||||
@Override
|
||||
public int executeUpdate(String sql) {
|
||||
return executeUpdate(new String[]{sql})[0];
|
||||
public int nativeUpdate(String sql) {
|
||||
return nativeUpdate(new String[]{sql})[0];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2503,7 +2503,7 @@ public class DataJdbcSource extends AbstractDataSqlSource {
|
||||
* @return 结果数组
|
||||
*/
|
||||
@Override
|
||||
public int[] executeUpdate(String... sqls) {
|
||||
public int[] nativeUpdate(String... sqls) {
|
||||
if (sqls.length == 0) {
|
||||
return new int[0];
|
||||
}
|
||||
@@ -2545,7 +2545,7 @@ public class DataJdbcSource extends AbstractDataSqlSource {
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public <V> V executeQuery(String sql, BiConsumer<Object, Object> consumer, Function<DataResultSet, V> handler) {
|
||||
public <V> V nativeQuery(String sql, BiConsumer<Object, Object> consumer, Function<DataResultSet, V> handler) {
|
||||
final long s = System.currentTimeMillis();
|
||||
final SourceConnection conn = readPool.pollConnection();
|
||||
try {
|
||||
@@ -2573,17 +2573,17 @@ public class DataJdbcSource extends AbstractDataSqlSource {
|
||||
|
||||
@Deprecated
|
||||
public int directExecute(String sql) {
|
||||
return executeUpdate(sql);
|
||||
return nativeUpdate(sql);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public int[] directExecute(String... sqls) {
|
||||
return executeUpdate(sqls);
|
||||
return nativeUpdate(sqls);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public <V> V directQuery(String sql, Function<DataResultSet, V> handler) {
|
||||
return executeQuery(sql, handler);
|
||||
return nativeQuery(sql, handler);
|
||||
}
|
||||
|
||||
public static DataResultSet createDataResultSet(@Nullable EntityInfo info, ResultSet set) {
|
||||
|
||||
@@ -94,17 +94,17 @@ public class DataMemorySource extends AbstractDataSqlSource implements SearchSou
|
||||
}
|
||||
|
||||
@Override
|
||||
public int executeUpdate(String sql) {
|
||||
public int nativeUpdate(String sql) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] executeUpdate(String... sqls) {
|
||||
public int[] nativeUpdate(String... sqls) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public <V> V executeQuery(String sql, BiConsumer<Object, Object> consumer, Function<DataResultSet, V> handler) {
|
||||
public <V> V nativeQuery(String sql, BiConsumer<Object, Object> consumer, Function<DataResultSet, V> handler) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
|
||||
@@ -19,19 +19,19 @@ import static org.redkale.source.DataResultSet.formatColumnValue;
|
||||
*/
|
||||
public interface DataSqlSource extends DataSource {
|
||||
|
||||
public int executeUpdate(String sql);
|
||||
public int nativeUpdate(String sql);
|
||||
|
||||
public int[] executeUpdate(String... sqls);
|
||||
public int[] nativeUpdate(String... sqls);
|
||||
|
||||
//BiConsumer 参数1: connection, 参数2: statement
|
||||
public <V> V executeQuery(String sql, BiConsumer<Object, Object> consumer, Function<DataResultSet, V> handler);
|
||||
public <V> V nativeQuery(String sql, BiConsumer<Object, Object> consumer, Function<DataResultSet, V> handler);
|
||||
|
||||
default <V> V executeQuery(String sql, Function<DataResultSet, V> handler) {
|
||||
return executeQuery(sql, null, handler);
|
||||
default <V> V nativeQuery(String sql, Function<DataResultSet, V> handler) {
|
||||
return nativeQuery(sql, null, handler);
|
||||
}
|
||||
|
||||
default <V> V executeQueryOne(Class<V> type, String sql) {
|
||||
return executeQuery(sql, rset -> {
|
||||
default <V> V nativeQueryOne(Class<V> type, String sql) {
|
||||
return nativeQuery(sql, rset -> {
|
||||
if (!rset.next()) {
|
||||
return null;
|
||||
}
|
||||
@@ -42,8 +42,8 @@ public interface DataSqlSource extends DataSource {
|
||||
});
|
||||
}
|
||||
|
||||
default <V> List<V> executeQueryList(Class<V> type, String sql) {
|
||||
return executeQuery(sql, rset -> {
|
||||
default <V> List<V> nativeQueryList(Class<V> type, String sql) {
|
||||
return nativeQuery(sql, rset -> {
|
||||
if (type.isPrimitive() || type == byte[].class || type.getName().startsWith("java.")) {
|
||||
List<V> list = new ArrayList<>();
|
||||
while (rset.next()) {
|
||||
@@ -55,8 +55,8 @@ public interface DataSqlSource extends DataSource {
|
||||
});
|
||||
}
|
||||
|
||||
default <K, V> Map<K, V> executeQueryMap(Class<K> keyType, Class<V> valType, String sql) {
|
||||
return executeQuery(sql, rset -> {
|
||||
default <K, V> Map<K, V> nativeQueryMap(Class<K> keyType, Class<V> valType, String sql) {
|
||||
return nativeQuery(sql, rset -> {
|
||||
Map<K, V> map = new LinkedHashMap<K, V>();
|
||||
while (rset.next()) {
|
||||
if (!rset.wasNull()) {
|
||||
@@ -67,11 +67,11 @@ public interface DataSqlSource extends DataSource {
|
||||
});
|
||||
}
|
||||
|
||||
default Map<String, String> executeQueryStrStrMap(String sql) {
|
||||
return executeQueryMap(String.class, String.class, sql);
|
||||
default Map<String, String> nativeQueryStrStrMap(String sql) {
|
||||
return nativeQueryMap(String.class, String.class, sql);
|
||||
}
|
||||
|
||||
default Map<Integer, String> executeQueryIntStrMap(String sql) {
|
||||
return executeQueryMap(Integer.class, String.class, sql);
|
||||
default Map<Integer, String> nativeQueryIntStrMap(String sql) {
|
||||
return nativeQueryMap(Integer.class, String.class, sql);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user