1
mirror of https://github.com/CarmJos/EasySQL.git synced 2024-09-19 21:35:47 +00:00

chore(sql): 尝试分离async部分

This commit is contained in:
Carm Jos 2022-12-22 09:35:02 +08:00
parent b6871b1000
commit 81f065a85a
71 changed files with 646 additions and 616 deletions

View File

@ -24,9 +24,9 @@ _SQLTable同时提供了有SQLManager参数与无参的操作方法其中无
首先,我们需要创建一个枚举类,[示例代码](../demo/src/main/java/DataTables1.java)如下所示: 首先,我们需要创建一个枚举类,[示例代码](../demo/src/main/java/DataTables1.java)如下所示:
```java ```java
import cc.carm.lib.easysql.api.enums.IndexType; import enums.cc.carm.lib.easysql.api.IndexType;
import cc.carm.lib.easysql.api.enums.NumberType; import enums.cc.carm.lib.easysql.api.NumberType;
import cc.carm.lib.easysql.api.table.NamedSQLTable; import table.cc.carm.lib.easysql.api.NamedSQLTable;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@ -91,9 +91,9 @@ _该方法为本人最常用也是最推荐的方法。_
[示例代码](../demo/src/main/java/DataTables2.java)如下: [示例代码](../demo/src/main/java/DataTables2.java)如下:
```java ```java
import cc.carm.lib.easysql.api.builder.TableCreateBuilder; import builder.cc.carm.lib.easysql.api.TableCreateBuilder;
import cc.carm.lib.easysql.api.enums.IndexType; import enums.cc.carm.lib.easysql.api.IndexType;
import cc.carm.lib.easysql.api.enums.NumberType; import enums.cc.carm.lib.easysql.api.NumberType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;

View File

@ -1,99 +0,0 @@
package cc.carm.lib.easysql.api;
import cc.carm.lib.easysql.api.builder.TableAlterBuilder;
import cc.carm.lib.easysql.api.builder.TableCreateBuilder;
import cc.carm.lib.easysql.api.builder.TableMetadataBuilder;
import cc.carm.lib.easysql.api.enums.IsolationLevel;
import cc.carm.lib.easysql.api.function.SQLBiFunction;
import cc.carm.lib.easysql.api.function.SQLFunction;
import cc.carm.lib.easysql.api.transaction.SQLTransaction;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.util.concurrent.CompletableFuture;
public interface NewSQLManager extends SQLSource, SQLOperator {
default @NotNull SQLTransaction createTransaction() {
return createTransaction(null);
}
@NotNull SQLTransaction createTransaction(@Nullable IsolationLevel level);
/**
* 在库中创建一个表
*
* @param tableName 表名
* @return {@link TableCreateBuilder}
*/
@NotNull TableCreateBuilder createTable(@NotNull String tableName);
/**
* 对库中的某个表执行更改
*
* @param tableName 表名
* @return {@link TableAlterBuilder}
*/
@NotNull TableAlterBuilder alterTable(@NotNull String tableName);
/**
* 快速获取表的部分元数据
* <br> 当需要获取其他元数据时请使用 {@link #fetchMetadata(SQLFunction, SQLFunction)} 方法
*
* @param tablePattern 表名通配符
* @return {@link TableMetadataBuilder}
*/
@NotNull TableMetadataBuilder fetchTableMetadata(@NotNull String tablePattern);
/**
* 获取并操作 {@link DatabaseMetaData} 以得到需要的数据库消息
*
* @param reader 操作与读取的方法
* @param <R> 最终结果的返回类型
* @return 最终结果通过 {@link CompletableFuture#get()} 可阻塞并等待结果返回
*/
default <R> CompletableFuture<R> fetchMetadata(@NotNull SQLFunction<DatabaseMetaData, R> reader) {
return fetchMetadata((meta, conn) -> reader.apply(meta));
}
/**
* 获取并操作 {@link DatabaseMetaData} 提供的指定 {@link ResultSet} 以得到需要的数据库消息
* <br> 该方法会自动关闭 {@link ResultSet}
*
* @param supplier 操作 {@link DatabaseMetaData} 以提供信息所在的 {@link ResultSet}
* @param reader 读取 {@link ResultSet} 中指定信息的方法
* @param <R> 最终结果的返回类型
* @return 最终结果通过 {@link CompletableFuture#get()} 可阻塞并等待结果返回
* @throws NullPointerException supplier 提供的 {@link ResultSet} 为NULL时抛出
*/
default <R> CompletableFuture<R> fetchMetadata(@NotNull SQLFunction<DatabaseMetaData, ResultSet> supplier,
@NotNull SQLFunction<@NotNull ResultSet, R> reader) {
return fetchMetadata((meta, conn) -> supplier.apply(meta), reader);
}
/**
* 获取并操作 {@link DatabaseMetaData} 以得到需要的数据库消息
*
* @param reader 操作与读取的方法
* @param <R> 最终结果的返回类型
* @return 最终结果通过 {@link CompletableFuture#get()} 可阻塞并等待结果返回
*/
<R> CompletableFuture<R> fetchMetadata(@NotNull SQLBiFunction<DatabaseMetaData, Connection, R> reader);
/**
* 获取并操作 {@link DatabaseMetaData} 提供的指定 {@link ResultSet} 以得到需要的数据库消息
* <br> 该方法会自动关闭 {@link ResultSet}
*
* @param supplier 操作 {@link DatabaseMetaData} 以提供信息所在的 {@link ResultSet}
* @param reader 读取 {@link ResultSet} 中指定信息的方法
* @param <R> 最终结果的返回类型
* @return 最终结果通过 {@link CompletableFuture#get()} 可阻塞并等待结果返回
* @throws NullPointerException supplier 提供的 {@link ResultSet} 为NULL时抛出
*/
<R> CompletableFuture<R> fetchMetadata(@NotNull SQLBiFunction<DatabaseMetaData, Connection, ResultSet> supplier,
@NotNull SQLFunction<@NotNull ResultSet, R> reader);
}

View File

@ -1,5 +1,6 @@
package cc.carm.lib.easysql.api; package cc.carm.lib.easysql.api;
import cc.carm.lib.easysql.api.action.SQLAction;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
/** /**

View File

@ -1,187 +1,107 @@
package cc.carm.lib.easysql.api; package cc.carm.lib.easysql.api;
import cc.carm.lib.easysql.api.action.PreparedSQLUpdateAction; import cc.carm.lib.easysql.api.action.asyncable.AsyncableBatchUpdateAction;
import cc.carm.lib.easysql.api.action.PreparedSQLUpdateBatchAction; import cc.carm.lib.easysql.api.action.asyncable.AsyncableUpdateAction;
import cc.carm.lib.easysql.api.action.SQLUpdateAction;
import cc.carm.lib.easysql.api.action.SQLUpdateBatchAction;
import cc.carm.lib.easysql.api.builder.*; import cc.carm.lib.easysql.api.builder.*;
import cc.carm.lib.easysql.api.enums.IsolationLevel;
import cc.carm.lib.easysql.api.function.SQLBiFunction; import cc.carm.lib.easysql.api.function.SQLBiFunction;
import cc.carm.lib.easysql.api.function.SQLDebugHandler;
import cc.carm.lib.easysql.api.function.SQLExceptionHandler;
import cc.carm.lib.easysql.api.function.SQLFunction; import cc.carm.lib.easysql.api.function.SQLFunction;
import cc.carm.lib.easysql.api.transaction.SQLTransaction;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import javax.sql.DataSource;
import java.sql.Connection; import java.sql.Connection;
import java.sql.DatabaseMetaData; import java.sql.DatabaseMetaData;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.function.Supplier;
/** public interface SQLManager extends SQLSource {
* SQLManager 是EasySQL的核心类用于管理数据库连接提供数据库操作的方法
*
* @author CarmJos
*/
public interface SQLManager {
Logger getLogger(); default @NotNull SQLTransaction createTransaction() {
return createTransaction(null);
/**
* 获取用于执行 {@link SQLAction#executeAsync()} 的线程池
* <br> 默认线程池为 {@link #defaultExecutorPool(String)}
*
* @return {@link ExecutorService}
*/
@NotNull ExecutorService getExecutorPool();
/**
* 设定用于执行 {@link SQLAction#executeAsync()} 的线程池.
* <br> 默认线程池为 {@link #defaultExecutorPool(String)}
*
* @param executorPool {@link ExecutorService}
*/
void setExecutorPool(@NotNull ExecutorService executorPool);
static ExecutorService defaultExecutorPool(String threadName) {
return Executors.newFixedThreadPool(4, r -> {
Thread thread = new Thread(r, threadName);
thread.setDaemon(true);
return thread;
});
} }
boolean isDebugMode(); @NotNull SQLTransaction createTransaction(@Nullable IsolationLevel level);
/** /**
* 设定是否启用调试模式 * 新建一个查询
* 启用调试模式后会在每次执行SQL语句时调用 {@link #getDebugHandler()} 来输出调试信息
* *
* @param debugMode 是否启用调试模式 * @return {@link QueryBuilder}
*/ */
void setDebugMode(@NotNull Supplier<@NotNull Boolean> debugMode); @NotNull QueryBuilder createQuery();
/** /**
* 设定是否启用调试模式 * 创建一条插入操作
* 启用调试模式后会在每次执行SQL语句时调用 {@link #getDebugHandler()} 来输出调试信息
* *
* @param enable 是否启用调试模式 * @param tableName 目标表名
* @return {@link InsertBuilder}
*/ */
default void setDebugMode(boolean enable) { @NotNull InsertBuilder<AsyncableUpdateAction<Integer>> insertInto(@NotNull String tableName);
setDebugMode(() -> enable);
}
/** /**
* 获取调试处理器用于处理调试信息 * 创建支持多组数据的插入操作
* *
* @return {@link SQLDebugHandler} * @param tableName 目标表名
* @return {@link InsertBuilder}
*/ */
@NotNull SQLDebugHandler getDebugHandler(); @NotNull InsertBuilder<AsyncableBatchUpdateAction<Integer>> insertBatchInto(@NotNull String tableName);
/** /**
* 设定调试处理器默认为 {@link SQLDebugHandler#defaultHandler(Logger)} * 创建一条替换操作
* *
* @param debugHandler {@link SQLDebugHandler} * @param tableName 目标表名
* @return {@link ReplaceBuilder}
*/ */
void setDebugHandler(@NotNull SQLDebugHandler debugHandler); @NotNull ReplaceBuilder<AsyncableUpdateAction<Integer>> replaceInto(@NotNull String tableName);
/** /**
* 得到连接池源 * 创建支持多组数据的替换操作
* *
* @return DataSource * @param tableName 目标表名
* @return {@link ReplaceBuilder}
*/ */
@NotNull DataSource getDataSource(); @NotNull ReplaceBuilder<AsyncableBatchUpdateAction<Integer>> replaceBatchInto(@NotNull String tableName);
/** /**
* 得到一个数据库连接实例 * 创建更新操作
* *
* @return Connection * @param tableName 目标表名
* @throws SQLException {@link DataSource#getConnection()} * @return {@link UpdateBuilder}
*/ */
@NotNull Connection getConnection() throws SQLException; @NotNull UpdateBuilder updateInto(@NotNull String tableName);
/** /**
* 得到正使用的查询 * 创建删除操作
* *
* @return 查询列表 * @param tableName 目标表名
* @return {@link DeleteBuilder}
*/ */
@NotNull Map<UUID, SQLQuery> getActiveQuery(); @NotNull DeleteBuilder deleteFrom(@NotNull String tableName);
/** /**
* 获取改管理器提供的默认异常处理器 * 在库中创建一个表
* 若未使用过 {@link #setExceptionHandler(SQLExceptionHandler)} 方法
* 则默认返回 {@link SQLExceptionHandler#detailed(Logger)}
* *
* @return {@link SQLExceptionHandler} * @param tableName 表名
* @return {@link TableCreateBuilder}
*/ */
@NotNull SQLExceptionHandler getExceptionHandler(); @NotNull TableCreateBuilder createTable(@NotNull String tableName);
/** /**
* 设定通用的异常处理器 * 对库中的某个表执行更改
* <br> 在使用 {@link SQLAction#execute(SQLExceptionHandler)} 等相关方法时若传入的处理器为null则会采用此处理器
* <br> 若该方法传入参数为 null则会使用 {@link SQLExceptionHandler#detailed(Logger)}
* *
* @param handler 异常处理器 * @param tableName 表名
* @return {@link TableAlterBuilder}
*/ */
void setExceptionHandler(@Nullable SQLExceptionHandler handler); @NotNull TableAlterBuilder alterTable(@NotNull String tableName);
/** /**
* 执行一条不需要返回结果的SQL语句(多用于UPDATEREPLACEDELETE方法) * 快速获取表的部分元数据
* 该方法使用 Statement 实现请注意SQL注入风险 * <br> 当需要获取其他元数据时请使用 {@link #fetchMetadata(SQLFunction, SQLFunction)} 方法
* *
* @param sql SQL语句内容 * @param tablePattern 表名通配符
* @return 更新的行数 * @return {@link TableMetadataBuilder}
* @see SQLUpdateAction
*/ */
@Nullable Integer executeSQL(String sql); @NotNull TableMetadataBuilder fetchTableMetadata(@NotNull String tablePattern);
/**
* 执行一条不需要返回结果的预处理SQL更改(UPDATEREPLACEDELETE)
*
* @param sql SQL语句内容
* @param params SQL语句中 ? 的对应参数
* @return 更新的行数
* @see PreparedSQLUpdateAction
*/
@Nullable Integer executeSQL(String sql, Object[] params);
/**
* 执行多条不需要返回结果的SQL更改(UPDATEREPLACEDELETE)
*
* @param sql SQL语句内容
* @param paramsBatch SQL语句中对应?的参数组
* @return 对应参数返回的行数
* @see PreparedSQLUpdateBatchAction
*/
@Nullable List<Integer> executeSQLBatch(String sql, Iterable<Object[]> paramsBatch);
/**
* 执行多条不需要返回结果的SQL
* 该方法使用 Statement 实现请注意SQL注入风险
*
* @param sql SQL语句内容
* @param moreSQL 更多SQL语句内容
* @return 对应参数返回的行数
* @see SQLUpdateBatchAction
*/
@Nullable List<Integer> executeSQLBatch(@NotNull String sql, String... moreSQL);
/**
* 执行多条不需要返回结果的SQL
*
* @param sqlBatch SQL语句内容
* @return 对应参数返回的行数
*/
@Nullable List<Integer> executeSQLBatch(@NotNull Iterable<String> sqlBatch);
/** /**
* 获取并操作 {@link DatabaseMetaData} 以得到需要的数据库消息 * 获取并操作 {@link DatabaseMetaData} 以得到需要的数据库消息
@ -204,8 +124,7 @@ public interface SQLManager {
* @return 最终结果通过 {@link CompletableFuture#get()} 可阻塞并等待结果返回 * @return 最终结果通过 {@link CompletableFuture#get()} 可阻塞并等待结果返回
* @throws NullPointerException supplier 提供的 {@link ResultSet} 为NULL时抛出 * @throws NullPointerException supplier 提供的 {@link ResultSet} 为NULL时抛出
*/ */
default <R> CompletableFuture<R> fetchMetadata(@NotNull SQLFunction<DatabaseMetaData, ResultSet> supplier, default <R> CompletableFuture<R> fetchMetadata(@NotNull SQLFunction<DatabaseMetaData, ResultSet> supplier, @NotNull SQLFunction<@NotNull ResultSet, R> reader) {
@NotNull SQLFunction<@NotNull ResultSet, R> reader) {
return fetchMetadata((meta, conn) -> supplier.apply(meta), reader); return fetchMetadata((meta, conn) -> supplier.apply(meta), reader);
} }
@ -228,87 +147,6 @@ public interface SQLManager {
* @return 最终结果通过 {@link CompletableFuture#get()} 可阻塞并等待结果返回 * @return 最终结果通过 {@link CompletableFuture#get()} 可阻塞并等待结果返回
* @throws NullPointerException supplier 提供的 {@link ResultSet} 为NULL时抛出 * @throws NullPointerException supplier 提供的 {@link ResultSet} 为NULL时抛出
*/ */
<R> CompletableFuture<R> fetchMetadata(@NotNull SQLBiFunction<DatabaseMetaData, Connection, ResultSet> supplier, <R> CompletableFuture<R> fetchMetadata(@NotNull SQLBiFunction<DatabaseMetaData, Connection, ResultSet> supplier, @NotNull SQLFunction<@NotNull ResultSet, R> reader);
@NotNull SQLFunction<@NotNull ResultSet, R> reader);
/**
* 在库中创建一个表
*
* @param tableName 表名
* @return {@link TableCreateBuilder}
*/
TableCreateBuilder createTable(@NotNull String tableName);
/**
* 对库中的某个表执行更改
*
* @param tableName 表名
* @return {@link TableAlterBuilder}
*/
TableAlterBuilder alterTable(@NotNull String tableName);
/**
* 快速获取表的部分元数据
* <br> 当需要获取其他元数据时请使用 {@link #fetchMetadata(SQLFunction, SQLFunction)} 方法
*
* @param tablePattern 表名通配符
* @return {@link TableMetadataBuilder}
*/
TableMetadataBuilder fetchTableMetadata(@NotNull String tablePattern);
/**
* 新建一个查询
*
* @return {@link QueryBuilder}
*/
QueryBuilder createQuery();
/**
* 创建一条插入操作
*
* @param tableName 目标表名
* @return {@link InsertBuilder}
*/
InsertBuilder<PreparedSQLUpdateAction<Integer>> insertInto(@NotNull String tableName);
/**
* 创建支持多组数据的插入操作
*
* @param tableName 目标表名
* @return {@link InsertBuilder}
*/
InsertBuilder<PreparedSQLUpdateBatchAction<Integer>> createInsertBatch(@NotNull String tableName);
/**
* 创建一条替换操作
*
* @param tableName 目标表名
* @return {@link ReplaceBuilder}
*/
ReplaceBuilder<PreparedSQLUpdateAction<Integer>> createReplace(@NotNull String tableName);
/**
* 创建支持多组数据的替换操作
*
* @param tableName 目标表名
* @return {@link ReplaceBuilder}
*/
ReplaceBuilder<PreparedSQLUpdateBatchAction<Integer>> createReplaceBatch(@NotNull String tableName);
/**
* 创建更新操作
*
* @param tableName 目标表名
* @return {@link UpdateBuilder}
*/
UpdateBuilder createUpdate(@NotNull String tableName);
/**
* 创建删除操作
*
* @param tableName 目标表名
* @return {@link DeleteBuilder}
*/
DeleteBuilder createDelete(@NotNull String tableName);
} }

View File

@ -1,65 +0,0 @@
package cc.carm.lib.easysql.api;
import cc.carm.lib.easysql.api.action.PreparedSQLUpdateAction;
import cc.carm.lib.easysql.api.action.PreparedSQLUpdateBatchAction;
import cc.carm.lib.easysql.api.builder.*;
import org.jetbrains.annotations.NotNull;
public interface SQLOperator {
/**
* 新建一个查询
*
* @return {@link QueryBuilder}
*/
@NotNull QueryBuilder createQuery();
/**
* 创建一条插入操作
*
* @param tableName 目标表名
* @return {@link InsertBuilder}
*/
@NotNull InsertBuilder<PreparedSQLUpdateAction<Integer>> insertInto(@NotNull String tableName);
/**
* 创建支持多组数据的插入操作
*
* @param tableName 目标表名
* @return {@link InsertBuilder}
*/
@NotNull InsertBuilder<PreparedSQLUpdateBatchAction<Integer>> insertBatchInto(@NotNull String tableName);
/**
* 创建一条替换操作
*
* @param tableName 目标表名
* @return {@link ReplaceBuilder}
*/
@NotNull ReplaceBuilder<PreparedSQLUpdateAction<Integer>> replaceInto(@NotNull String tableName);
/**
* 创建支持多组数据的替换操作
*
* @param tableName 目标表名
* @return {@link ReplaceBuilder}
*/
@NotNull ReplaceBuilder<PreparedSQLUpdateBatchAction<Integer>> replaceBatchInto(@NotNull String tableName);
/**
* 创建更新操作
*
* @param tableName 目标表名
* @return {@link UpdateBuilder}
*/
@NotNull UpdateBuilder updateInto(@NotNull String tableName);
/**
* 创建删除操作
*
* @param tableName 目标表名
* @return {@link DeleteBuilder}
*/
@NotNull DeleteBuilder deleteFrom(@NotNull String tableName);
}

View File

@ -1,7 +1,7 @@
package cc.carm.lib.easysql.api; package cc.carm.lib.easysql.api;
import cc.carm.lib.easysql.api.action.query.PreparedQueryAction;
import cc.carm.lib.easysql.api.action.query.QueryAction; import cc.carm.lib.easysql.api.action.query.QueryAction;
import cc.carm.lib.easysql.api.action.query.PreparedQueryAction;
import java.sql.Connection; import java.sql.Connection;
import java.sql.ResultSet; import java.sql.ResultSet;

View File

@ -1,9 +1,10 @@
package cc.carm.lib.easysql.api; package cc.carm.lib.easysql.api;
import cc.carm.lib.easysql.api.action.PreparedSQLUpdateAction; import cc.carm.lib.easysql.api.action.*;
import cc.carm.lib.easysql.api.action.PreparedSQLUpdateBatchAction; import cc.carm.lib.easysql.api.action.base.PreparedBatchUpdateAction;
import cc.carm.lib.easysql.api.action.SQLUpdateAction; import cc.carm.lib.easysql.api.action.base.PreparedUpdateAction;
import cc.carm.lib.easysql.api.action.SQLUpdateBatchAction; import cc.carm.lib.easysql.api.action.base.BatchUpdateAction;
import cc.carm.lib.easysql.api.action.base.UpdateAction;
import cc.carm.lib.easysql.api.function.SQLDebugHandler; import cc.carm.lib.easysql.api.function.SQLDebugHandler;
import cc.carm.lib.easysql.api.function.SQLExceptionHandler; import cc.carm.lib.easysql.api.function.SQLExceptionHandler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -128,7 +129,7 @@ public interface SQLSource {
* *
* @param sql SQL语句内容 * @param sql SQL语句内容
* @return 更新的行数 * @return 更新的行数
* @see SQLUpdateAction * @see UpdateAction
*/ */
@Nullable Integer executeSQL(String sql); @Nullable Integer executeSQL(String sql);
@ -138,7 +139,7 @@ public interface SQLSource {
* @param sql SQL语句内容 * @param sql SQL语句内容
* @param params SQL语句中 ? 的对应参数 * @param params SQL语句中 ? 的对应参数
* @return 更新的行数 * @return 更新的行数
* @see PreparedSQLUpdateAction * @see PreparedUpdateAction
*/ */
@Nullable Integer executeSQL(String sql, Object[] params); @Nullable Integer executeSQL(String sql, Object[] params);
@ -148,7 +149,7 @@ public interface SQLSource {
* @param sql SQL语句内容 * @param sql SQL语句内容
* @param paramsBatch SQL语句中对应?的参数组 * @param paramsBatch SQL语句中对应?的参数组
* @return 对应参数返回的行数 * @return 对应参数返回的行数
* @see PreparedSQLUpdateBatchAction * @see PreparedBatchUpdateAction
*/ */
@Nullable List<Integer> executeSQLBatch(String sql, Iterable<Object[]> paramsBatch); @Nullable List<Integer> executeSQLBatch(String sql, Iterable<Object[]> paramsBatch);
@ -160,7 +161,7 @@ public interface SQLSource {
* @param sql SQL语句内容 * @param sql SQL语句内容
* @param moreSQL 更多SQL语句内容 * @param moreSQL 更多SQL语句内容
* @return 对应参数返回的行数 * @return 对应参数返回的行数
* @see SQLUpdateBatchAction * @see BatchUpdateAction
*/ */
@Nullable List<Integer> executeSQLBatch(@NotNull String sql, String... moreSQL); @Nullable List<Integer> executeSQLBatch(@NotNull String sql, String... moreSQL);

View File

@ -1,24 +0,0 @@
package cc.carm.lib.easysql.api.action;
import org.jetbrains.annotations.Nullable;
public interface PreparedSQLUpdateAction<T extends Number> extends SQLUpdateAction<T> {
/**
* 设定SQL语句中所有 ? 对应的参数
*
* @param params 参数内容
* @return {@link PreparedSQLUpdateAction}
*/
PreparedSQLUpdateAction<T> values(Object... params);
/**
* 设定SQL语句中所有 ? 对应的参数
*
* @param params 参数内容
* @return {@link PreparedSQLUpdateAction}
* @since 0.4.0
*/
PreparedSQLUpdateAction<T> values(@Nullable Iterable<Object> params);
}

View File

@ -1,4 +1,4 @@
package cc.carm.lib.easysql.api; package cc.carm.lib.easysql.api.action;
import cc.carm.lib.easysql.api.function.SQLExceptionHandler; import cc.carm.lib.easysql.api.function.SQLExceptionHandler;
import cc.carm.lib.easysql.api.function.SQLFunction; import cc.carm.lib.easysql.api.function.SQLFunction;
@ -16,25 +16,6 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
/**
* SQLAction 是用于承载SQL语句并进行处理返回的基本类
*
* <ul>
* <li>同步执行 {@link #execute()}, {@link #execute(SQLFunction, SQLExceptionHandler)}
* <br>同步执行方法中有会抛出异常的方法与不抛出异常的方法
* <br>若选择不抛出异常则返回值可能为空需要特殊处理</li>
*
* <li>异步执行 {@link #executeAsync(SQLHandler, SQLExceptionHandler)}
* <br>异步执行时将提供成功与异常两种处理方式
* <br>可自行选择是否对数据或异常进行处理
* <br>默认的异常处理器为 {@link #defaultExceptionHandler()}
* <br>若有特殊需要可通过{@link #setExceptionHandler(SQLExceptionHandler)} 方法修改默认的处理器</li>
* </ul>
*
* @param <T> 需要返回的类型
* @author CarmJos
* @since 0.0.1
*/
public interface SQLAction<T> { public interface SQLAction<T> {
/** /**

View File

@ -0,0 +1,55 @@
package cc.carm.lib.easysql.api.action;
import cc.carm.lib.easysql.api.function.SQLExceptionHandler;
import cc.carm.lib.easysql.api.function.SQLFunction;
import cc.carm.lib.easysql.api.function.SQLHandler;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Future;
public interface SQLAsyncableAction<T> extends SQLAction<T> {
/**
* 异步执行SQL语句采用默认异常处理无需返回值
*/
default void executeAsync() {
executeAsync(null);
}
/**
* 异步执行SQL语句
*
* @param success 成功时的操作
*/
default void executeAsync(@Nullable SQLHandler<T> success) {
executeAsync(success, null);
}
/**
* 异步执行SQL语句
*
* @param success 成功时的操作
* @param failure 异常处理器 默认为 {@link SQLAction#defaultExceptionHandler()}
*/
void executeAsync(@Nullable SQLHandler<T> success,
@Nullable SQLExceptionHandler failure);
/**
* 以异步Future方式执行SQL语句
*
* @return 异步执行的Future实例可通过 {@link Future#get()} 阻塞并等待结果
*/
default @NotNull CompletableFuture<Void> executeFuture() {
return executeFuture((t -> null));
}
/**
* 以异步Future方式执行SQL语句
*
* @return 异步执行的Future实例可通过 {@link Future#get()} 阻塞并等待结果
*/
<R> @NotNull CompletableFuture<R> executeFuture(@NotNull SQLFunction<T, R> handler);
}

View File

@ -0,0 +1,28 @@
package cc.carm.lib.easysql.api.action.asyncable;
import cc.carm.lib.easysql.api.action.SQLAsyncableAction;
import cc.carm.lib.easysql.api.action.base.BatchUpdateAction;
import org.jetbrains.annotations.NotNull;
import java.util.List;
@SuppressWarnings("UnusedReturnValue")
public interface AsyncableBatchUpdateAction
extends SQLAsyncableAction<List<Integer>> {
/**
* 添加一条批量执行的SQL语句
*
* @param sql SQL语句
* @return {@link BatchUpdateAction}
*/
BatchUpdateAction addBatch(@NotNull String sql);
@Override
default @NotNull String getSQLContent() {
return getSQLContents().get(0);
}
@Override
@NotNull List<String> getSQLContents();
}

View File

@ -0,0 +1,43 @@
package cc.carm.lib.easysql.api.action.asyncable;
import cc.carm.lib.easysql.api.action.SQLAsyncableAction;
import cc.carm.lib.easysql.api.action.base.UpdateAction;
import java.util.List;
public interface AsyncablePreparedBatchUpdateAction<T extends Number> extends SQLAsyncableAction<List<T>> {
/**
* 设定多组SQL语句中所有 ? 对应的参数
*
* @param allValues 所有参数内容
* @return {@link AsyncablePreparedBatchUpdateAction}
*/
AsyncablePreparedBatchUpdateAction<T> allValues(Iterable<Object[]> allValues);
/**
* 添加一组SQL语句中所有 ? 对应的参数
*
* @param values 参数内容
* @return {@link AsyncablePreparedBatchUpdateAction}
*/
AsyncablePreparedBatchUpdateAction<T> values(Object... values);
/**
* 设定该操作返回自增键序列
*
* @return {@link UpdateAction}
*/
AsyncablePreparedBatchUpdateAction<T> returnGeneratedKeys();
/**
* 设定该操作返回自增键序列
*
* @param keyTypeClass 自增序列的数字类型
* @param <N> 自增键序列类型 {@link Number}
* @return {@link UpdateAction}
* @since 0.4.0
*/
<N extends Number> AsyncablePreparedBatchUpdateAction<N> returnGeneratedKeys(Class<N> keyTypeClass);
}

View File

@ -0,0 +1,26 @@
package cc.carm.lib.easysql.api.action.asyncable;
import cc.carm.lib.easysql.api.action.base.PreparedUpdateAction;
import org.jetbrains.annotations.Nullable;
public interface AsyncablePreparedUpdateAction<T extends Number>
extends AsyncableUpdateAction<T> {
/**
* 设定SQL语句中所有 ? 对应的参数
*
* @param params 参数内容
* @return {@link PreparedUpdateAction}
*/
AsyncablePreparedUpdateAction<T> values(Object... params);
/**
* 设定SQL语句中所有 ? 对应的参数
*
* @param params 参数内容
* @return {@link PreparedUpdateAction}
* @since 0.4.0
*/
AsyncablePreparedUpdateAction<T> values(@Nullable Iterable<Object> params);
}

View File

@ -0,0 +1,9 @@
package cc.carm.lib.easysql.api.action.asyncable;
import cc.carm.lib.easysql.api.action.SQLAsyncableAction;
import cc.carm.lib.easysql.api.newactions.SQLUpdateAction;
public interface AsyncableUpdateAction<T extends Number>
extends SQLUpdateAction<T>, SQLAsyncableAction<T> {
}

View File

@ -0,0 +1,27 @@
package cc.carm.lib.easysql.api.action.base;
import cc.carm.lib.easysql.api.action.SQLAction;
import org.jetbrains.annotations.NotNull;
import java.util.List;
@SuppressWarnings("UnusedReturnValue")
public interface BatchUpdateAction extends SQLAction<List<Integer>> {
/**
* 添加一条批量执行的SQL语句
*
* @param sql SQL语句
* @return {@link BatchUpdateAction}
*/
BatchUpdateAction addBatch(@NotNull String sql);
@Override
default @NotNull String getSQLContent() {
return getSQLContents().get(0);
}
@Override
@NotNull List<String> getSQLContents();
}

View File

@ -0,0 +1,42 @@
package cc.carm.lib.easysql.api.action.base;
import cc.carm.lib.easysql.api.action.SQLAction;
import java.util.List;
public interface PreparedBatchUpdateAction<T extends Number> extends SQLAction<List<T>> {
/**
* 设定多组SQL语句中所有 ? 对应的参数
*
* @param allValues 所有参数内容
* @return {@link PreparedBatchUpdateAction}
*/
PreparedBatchUpdateAction<T> allValues(Iterable<Object[]> allValues);
/**
* 添加一组SQL语句中所有 ? 对应的参数
*
* @param values 参数内容
* @return {@link PreparedBatchUpdateAction}
*/
PreparedBatchUpdateAction<T> values(Object... values);
/**
* 设定该操作返回自增键序列
*
* @return {@link UpdateAction}
*/
PreparedBatchUpdateAction<T> returnGeneratedKeys();
/**
* 设定该操作返回自增键序列
*
* @param keyTypeClass 自增序列的数字类型
* @param <N> 自增键序列类型 {@link Number}
* @return {@link UpdateAction}
* @since 0.4.0
*/
<N extends Number> PreparedBatchUpdateAction<N> returnGeneratedKeys(Class<N> keyTypeClass);
}

View File

@ -0,0 +1,24 @@
package cc.carm.lib.easysql.api.action.base;
import org.jetbrains.annotations.Nullable;
public interface PreparedUpdateAction<T extends Number> extends UpdateAction<T> {
/**
* 设定SQL语句中所有 ? 对应的参数
*
* @param params 参数内容
* @return {@link PreparedUpdateAction}
*/
PreparedUpdateAction<T> values(Object... params);
/**
* 设定SQL语句中所有 ? 对应的参数
*
* @param params 参数内容
* @return {@link PreparedUpdateAction}
* @since 0.4.0
*/
PreparedUpdateAction<T> values(@Nullable Iterable<Object> params);
}

View File

@ -0,0 +1,25 @@
package cc.carm.lib.easysql.api.action.base;
import cc.carm.lib.easysql.api.action.SQLAction;
public interface UpdateAction<T extends Number> extends SQLAction<T> {
/**
* 设定该操作返回自增键序列
*
* @return {@link UpdateAction}
*/
UpdateAction<T> returnGeneratedKey();
/**
* 设定该操作返回自增键序列
*
* @param keyTypeClass 自增序列的数字类型
* @param <N> 自增键序列类型 {@link Number}
* @return {@link UpdateAction}
* @since 0.4.0
*/
<N extends Number> UpdateAction<N> returnGeneratedKey(Class<N> keyTypeClass);
}

View File

@ -1,9 +1,8 @@
package cc.carm.lib.easysql.api.action.query; package cc.carm.lib.easysql.api.action.query;
import cc.carm.lib.easysql.api.SQLAction; import cc.carm.lib.easysql.api.function.SQLFunction;
import cc.carm.lib.easysql.api.SQLQuery; import cc.carm.lib.easysql.api.SQLQuery;
import cc.carm.lib.easysql.api.function.SQLExceptionHandler; import cc.carm.lib.easysql.api.function.SQLExceptionHandler;
import cc.carm.lib.easysql.api.function.SQLFunction;
import cc.carm.lib.easysql.api.function.SQLHandler; import cc.carm.lib.easysql.api.function.SQLHandler;
import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;

View File

@ -1,6 +1,5 @@
package cc.carm.lib.easysql.api.builder; package cc.carm.lib.easysql.api.builder;
import cc.carm.lib.easysql.api.SQLAction;
import cc.carm.lib.easysql.api.SQLBuilder; import cc.carm.lib.easysql.api.SQLBuilder;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;

View File

@ -1,7 +1,5 @@
package cc.carm.lib.easysql.api.builder; package cc.carm.lib.easysql.api.builder;
import cc.carm.lib.easysql.api.SQLAction;
public interface DeleteBuilder extends ConditionalBuilder<DeleteBuilder, SQLAction<Integer>> { public interface DeleteBuilder extends ConditionalBuilder<DeleteBuilder, SQLAction<Integer>> {
String getTableName(); String getTableName();

View File

@ -1,11 +1,9 @@
package cc.carm.lib.easysql.api.builder; package cc.carm.lib.easysql.api.builder;
import cc.carm.lib.easysql.api.SQLAction;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
public interface InsertBuilder<T extends SQLAction<?>> { public interface InsertBuilder<T> {
String getTableName(); String getTableName();

View File

@ -1,8 +1,8 @@
package cc.carm.lib.easysql.api.builder; package cc.carm.lib.easysql.api.builder;
import cc.carm.lib.easysql.api.SQLBuilder; import cc.carm.lib.easysql.api.SQLBuilder;
import cc.carm.lib.easysql.api.action.query.PreparedQueryAction;
import cc.carm.lib.easysql.api.action.query.QueryAction; import cc.carm.lib.easysql.api.action.query.QueryAction;
import cc.carm.lib.easysql.api.action.query.PreparedQueryAction;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
public interface QueryBuilder extends SQLBuilder { public interface QueryBuilder extends SQLBuilder {

View File

@ -1,7 +1,5 @@
package cc.carm.lib.easysql.api.builder; package cc.carm.lib.easysql.api.builder;
import cc.carm.lib.easysql.api.SQLAction;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;

View File

@ -1,8 +1,7 @@
package cc.carm.lib.easysql.api.builder; package cc.carm.lib.easysql.api.builder;
import cc.carm.lib.easysql.api.SQLAction;
import cc.carm.lib.easysql.api.SQLBuilder; import cc.carm.lib.easysql.api.SQLBuilder;
import cc.carm.lib.easysql.api.action.SQLUpdateAction; import cc.carm.lib.easysql.api.action.base.UpdateAction;
import cc.carm.lib.easysql.api.enums.IndexType; import cc.carm.lib.easysql.api.enums.IndexType;
import cc.carm.lib.easysql.api.enums.NumberType; import cc.carm.lib.easysql.api.enums.NumberType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -23,7 +22,7 @@ public interface TableAlterBuilder extends SQLBuilder {
* 为该表移除一个索引 * 为该表移除一个索引
* *
* @param indexName 索引名 * @param indexName 索引名
* @return {@link SQLUpdateAction} * @return {@link UpdateAction}
*/ */
SQLAction<Integer> dropIndex(@NotNull String indexName); SQLAction<Integer> dropIndex(@NotNull String indexName);
@ -31,14 +30,14 @@ public interface TableAlterBuilder extends SQLBuilder {
* 为该表移除一个外键 * 为该表移除一个外键
* *
* @param keySymbol 外键名 * @param keySymbol 外键名
* @return {@link SQLUpdateAction} * @return {@link UpdateAction}
*/ */
SQLAction<Integer> dropForeignKey(@NotNull String keySymbol); SQLAction<Integer> dropForeignKey(@NotNull String keySymbol);
/** /**
* 为该表移除主键(须添加新主键) * 为该表移除主键(须添加新主键)
* *
* @return {@link SQLUpdateAction} * @return {@link UpdateAction}
*/ */
SQLAction<Integer> dropPrimaryKey(); SQLAction<Integer> dropPrimaryKey();
@ -47,7 +46,7 @@ public interface TableAlterBuilder extends SQLBuilder {
* *
* @param columnName 列名 * @param columnName 列名
* @param settings 列的相关设定 * @param settings 列的相关设定
* @return {@link SQLUpdateAction} * @return {@link UpdateAction}
*/ */
default SQLAction<Integer> addColumn(@NotNull String columnName, @NotNull String settings) { default SQLAction<Integer> addColumn(@NotNull String columnName, @NotNull String settings) {
return addColumn(columnName, settings, null); return addColumn(columnName, settings, null);
@ -61,7 +60,7 @@ public interface TableAlterBuilder extends SQLBuilder {
* @param afterColumn 该列增添到哪个列的后面 * @param afterColumn 该列增添到哪个列的后面
* <p> 该参数若省缺则放于最后一行 * <p> 该参数若省缺则放于最后一行
* <p> 若为 "" 则置于首行 * <p> 若为 "" 则置于首行
* @return {@link SQLUpdateAction} * @return {@link UpdateAction}
*/ */
SQLAction<Integer> addColumn(@NotNull String columnName, @NotNull String settings, @Nullable String afterColumn); SQLAction<Integer> addColumn(@NotNull String columnName, @NotNull String settings, @Nullable String afterColumn);

View File

@ -1,7 +1,7 @@
package cc.carm.lib.easysql.api.builder; package cc.carm.lib.easysql.api.builder;
import cc.carm.lib.easysql.api.SQLBuilder; import cc.carm.lib.easysql.api.SQLBuilder;
import cc.carm.lib.easysql.api.action.SQLUpdateAction; import cc.carm.lib.easysql.api.action.base.UpdateAction;
import cc.carm.lib.easysql.api.enums.ForeignKeyRule; import cc.carm.lib.easysql.api.enums.ForeignKeyRule;
import cc.carm.lib.easysql.api.enums.IndexType; import cc.carm.lib.easysql.api.enums.IndexType;
import cc.carm.lib.easysql.api.enums.NumberType; import cc.carm.lib.easysql.api.enums.NumberType;
@ -19,9 +19,9 @@ public interface TableCreateBuilder extends SQLBuilder {
/** /**
* 将现有条件构建完整的SQL语句用于执行 * 将现有条件构建完整的SQL语句用于执行
* *
* @return {@link SQLUpdateAction} * @return {@link UpdateAction}
*/ */
SQLUpdateAction<Integer> build(); UpdateAction<Integer> build();
@NotNull String getTableName(); @NotNull String getTableName();

View File

@ -1,6 +1,5 @@
package cc.carm.lib.easysql.api.builder; package cc.carm.lib.easysql.api.builder;
import cc.carm.lib.easysql.api.SQLAction;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;

View File

@ -1,5 +1,7 @@
package cc.carm.lib.easysql.api.enums; package cc.carm.lib.easysql.api.enums;
import java.sql.Connection;
/** /**
* 事务隔离级别 * 事务隔离级别
* 部分Javadoc来自文章 <a href="https://cloud.tencent.com/developer/article/1865041">理解事务的4种隔离级别</a> * 部分Javadoc来自文章 <a href="https://cloud.tencent.com/developer/article/1865041">理解事务的4种隔离级别</a>
@ -9,19 +11,29 @@ public enum IsolationLevel {
/** /**
* 读未提交即一个事务可以读取另一个未提交事务的数据 * 读未提交即一个事务可以读取另一个未提交事务的数据
*/ */
READ_UNCOMMITTED, READ_UNCOMMITTED(Connection.TRANSACTION_READ_UNCOMMITTED),
/** /**
* 读提交即一个事务要等另一个事务提交后才能读取数据 * 读提交即一个事务要等另一个事务提交后才能读取数据
*/ */
READ_COMMITTED, READ_COMMITTED(Connection.TRANSACTION_READ_COMMITTED),
/** /**
* 重复读即在开始读取数据事务开启不再允许修改操作 * 重复读即在开始读取数据事务开启不再允许修改操作
*/ */
REPEATED_READ, REPEATED_READ(Connection.TRANSACTION_REPEATABLE_READ),
/** /**
* 序列化读取此为最高隔离等级在该级别下事务串行化顺序执行可以避免脏读不可重复读与幻读 * 序列化读取此为最高隔离等级在该级别下事务串行化顺序执行可以避免脏读不可重复读与幻读
* <br>注意 这种事务隔离级别效率低下比较耗数据库性能一般不使用 * <br>注意 这种事务隔离级别效率低下比较耗数据库性能一般不使用
*/ */
SERIALIZABLE; SERIALIZABLE(Connection.TRANSACTION_SERIALIZABLE);
private int id;
IsolationLevel(int id) {
this.id = id;
}
public int getID() {
return id;
}
} }

View File

@ -1,9 +1,8 @@
package cc.carm.lib.easysql.api.function; package cc.carm.lib.easysql.api.function;
import cc.carm.lib.easysql.api.SQLAction;
import cc.carm.lib.easysql.api.SQLQuery; import cc.carm.lib.easysql.api.SQLQuery;
import cc.carm.lib.easysql.api.action.PreparedSQLUpdateAction; import cc.carm.lib.easysql.api.action.base.PreparedUpdateAction;
import cc.carm.lib.easysql.api.action.PreparedSQLUpdateBatchAction; import cc.carm.lib.easysql.api.action.base.PreparedBatchUpdateAction;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -24,7 +23,7 @@ public interface SQLDebugHandler {
* *
* @param action {@link SQLAction} 对象 * @param action {@link SQLAction} 对象
* @param params 执行传入的参数列表 * @param params 执行传入的参数列表
* 实际上仅有 {@link PreparedSQLUpdateAction} {@link PreparedSQLUpdateBatchAction} 才会有传入参数 * 实际上仅有 {@link PreparedUpdateAction} {@link PreparedBatchUpdateAction} 才会有传入参数
*/ */
void beforeExecute(@NotNull SQLAction<?> action, @NotNull List<@Nullable Object[]> params); void beforeExecute(@NotNull SQLAction<?> action, @NotNull List<@Nullable Object[]> params);

View File

@ -1,6 +1,6 @@
package cc.carm.lib.easysql.api.function; package cc.carm.lib.easysql.api.function;
import cc.carm.lib.easysql.api.SQLAction; import cc.carm.lib.easysql.api.action.SQLAction;
import org.slf4j.Logger; import org.slf4j.Logger;
import java.sql.SQLException; import java.sql.SQLException;

View File

@ -1,33 +1,33 @@
package cc.carm.lib.easysql.api.action; package cc.carm.lib.easysql.api.newactions;
import cc.carm.lib.easysql.api.SQLAction; import cc.carm.lib.easysql.api.action.SQLAction;
import java.util.List; import java.util.List;
public interface PreparedSQLUpdateBatchAction<T extends Number> extends SQLAction<List<T>> { public interface PreparedBatchUpdateAction<T extends Number> extends SQLAction<List<T>> {
/** /**
* 设定多组SQL语句中所有 ? 对应的参数 * 设定多组SQL语句中所有 ? 对应的参数
* *
* @param allValues 所有参数内容 * @param allValues 所有参数内容
* @return {@link PreparedSQLUpdateBatchAction} * @return {@link PreparedBatchUpdateAction}
*/ */
PreparedSQLUpdateBatchAction<T> allValues(Iterable<Object[]> allValues); PreparedBatchUpdateAction<T> allValues(Iterable<Object[]> allValues);
/** /**
* 添加一组SQL语句中所有 ? 对应的参数 * 添加一组SQL语句中所有 ? 对应的参数
* *
* @param values 参数内容 * @param values 参数内容
* @return {@link PreparedSQLUpdateBatchAction} * @return {@link PreparedBatchUpdateAction}
*/ */
PreparedSQLUpdateBatchAction<T> values(Object... values); PreparedBatchUpdateAction<T> values(Object... values);
/** /**
* 设定该操作返回自增键序列 * 设定该操作返回自增键序列
* *
* @return {@link SQLUpdateAction} * @return {@link SQLUpdateAction}
*/ */
PreparedSQLUpdateBatchAction<T> returnGeneratedKeys(); PreparedBatchUpdateAction<T> returnGeneratedKeys();
/** /**
* 设定该操作返回自增键序列 * 设定该操作返回自增键序列
@ -37,6 +37,6 @@ public interface PreparedSQLUpdateBatchAction<T extends Number> extends SQLActio
* @return {@link SQLUpdateAction} * @return {@link SQLUpdateAction}
* @since 0.4.0 * @since 0.4.0
*/ */
<N extends Number> PreparedSQLUpdateBatchAction<N> returnGeneratedKeys(Class<N> keyTypeClass); <N extends Number> PreparedBatchUpdateAction<N> returnGeneratedKeys(Class<N> keyTypeClass);
} }

View File

@ -0,0 +1,24 @@
package cc.carm.lib.easysql.api.newactions;
import org.jetbrains.annotations.Nullable;
public interface PreparedUpdateAction<T extends Number> extends SQLUpdateAction<T> {
/**
* 设定SQL语句中所有 ? 对应的参数
*
* @param params 参数内容
* @return {@link PreparedUpdateAction}
*/
PreparedUpdateAction<T> values(Object... params);
/**
* 设定SQL语句中所有 ? 对应的参数
*
* @param params 参数内容
* @return {@link PreparedUpdateAction}
* @since 0.4.0
*/
PreparedUpdateAction<T> values(@Nullable Iterable<Object> params);
}

View File

@ -1,20 +1,19 @@
package cc.carm.lib.easysql.api.action; package cc.carm.lib.easysql.api.newactions;
import cc.carm.lib.easysql.api.SQLAction;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.List; import java.util.List;
@SuppressWarnings("UnusedReturnValue") @SuppressWarnings("UnusedReturnValue")
public interface SQLUpdateBatchAction extends SQLAction<List<Integer>> { public interface SQLBatchUpdateAction extends SQLAction<List<Integer>> {
/** /**
* 添加一条批量执行的SQL语句 * 添加一条批量执行的SQL语句
* *
* @param sql SQL语句 * @param sql SQL语句
* @return {@link SQLUpdateBatchAction} * @return {@link SQLBatchUpdateAction}
*/ */
SQLUpdateBatchAction addBatch(@NotNull String sql); SQLBatchUpdateAction addBatch(@NotNull String sql);
@Override @Override
default @NotNull String getSQLContent() { default @NotNull String getSQLContent() {

View File

@ -1,6 +1,4 @@
package cc.carm.lib.easysql.api.action; package cc.carm.lib.easysql.api.newactions;
import cc.carm.lib.easysql.api.SQLAction;
public interface SQLUpdateAction<T extends Number> extends SQLAction<T> { public interface SQLUpdateAction<T extends Number> extends SQLAction<T> {

View File

@ -1,6 +1,5 @@
package cc.carm.lib.easysql.api.table; package cc.carm.lib.easysql.api.table;
import cc.carm.lib.easysql.api.SQLManager;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;

View File

@ -1,11 +1,10 @@
package cc.carm.lib.easysql.api.table; package cc.carm.lib.easysql.api.table;
import cc.carm.lib.easysql.api.SQLManager; import cc.carm.lib.easysql.api.action.base.PreparedUpdateAction;
import cc.carm.lib.easysql.api.action.PreparedSQLUpdateAction; import cc.carm.lib.easysql.api.action.base.PreparedBatchUpdateAction;
import cc.carm.lib.easysql.api.action.PreparedSQLUpdateBatchAction;
import cc.carm.lib.easysql.api.builder.*; import cc.carm.lib.easysql.api.builder.*;
import cc.carm.lib.easysql.api.old.builder.*;
import cc.carm.lib.easysql.api.function.SQLHandler; import cc.carm.lib.easysql.api.function.SQLHandler;
import cc.carm.lib.easysql.api.table.NamedSQLTable;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@ -101,40 +100,40 @@ public interface SQLTable {
return sqlManager.createUpdate(getTableName()); return sqlManager.createUpdate(getTableName());
} }
default @NotNull InsertBuilder<PreparedSQLUpdateAction<Integer>> createInsert() { default @NotNull InsertBuilder<PreparedUpdateAction<Integer>> createInsert() {
return Optional.ofNullable(getSQLManager()).map(this::createInsert) return Optional.ofNullable(getSQLManager()).map(this::createInsert)
.orElseThrow(() -> new NullPointerException("This table doesn't have a SQLManger.")); .orElseThrow(() -> new NullPointerException("This table doesn't have a SQLManger."));
} }
default @NotNull InsertBuilder<PreparedSQLUpdateAction<Integer>> createInsert(@NotNull SQLManager sqlManager) { default @NotNull InsertBuilder<PreparedUpdateAction<Integer>> createInsert(@NotNull SQLManager sqlManager) {
return sqlManager.insertInto(getTableName()); return sqlManager.insertInto(getTableName());
} }
default @NotNull InsertBuilder<PreparedSQLUpdateBatchAction<Integer>> createInsertBatch() { default @NotNull InsertBuilder<PreparedBatchUpdateAction<Integer>> createInsertBatch() {
return Optional.ofNullable(getSQLManager()).map(this::createInsertBatch) return Optional.ofNullable(getSQLManager()).map(this::createInsertBatch)
.orElseThrow(() -> new NullPointerException("This table doesn't have a SQLManger.")); .orElseThrow(() -> new NullPointerException("This table doesn't have a SQLManger."));
} }
default @NotNull InsertBuilder<PreparedSQLUpdateBatchAction<Integer>> createInsertBatch(@NotNull SQLManager sqlManager) { default @NotNull InsertBuilder<PreparedBatchUpdateAction<Integer>> createInsertBatch(@NotNull SQLManager sqlManager) {
return sqlManager.createInsertBatch(getTableName()); return sqlManager.createInsertBatch(getTableName());
} }
default @NotNull ReplaceBuilder<PreparedSQLUpdateAction<Integer>> createReplace() { default @NotNull ReplaceBuilder<PreparedUpdateAction<Integer>> createReplace() {
return Optional.ofNullable(getSQLManager()).map(this::createReplace) return Optional.ofNullable(getSQLManager()).map(this::createReplace)
.orElseThrow(() -> new NullPointerException("This table doesn't have a SQLManger.")); .orElseThrow(() -> new NullPointerException("This table doesn't have a SQLManger."));
} }
default @NotNull ReplaceBuilder<PreparedSQLUpdateAction<Integer>> createReplace(@NotNull SQLManager sqlManager) { default @NotNull ReplaceBuilder<PreparedUpdateAction<Integer>> createReplace(@NotNull SQLManager sqlManager) {
return sqlManager.createReplace(getTableName()); return sqlManager.createReplace(getTableName());
} }
default @NotNull ReplaceBuilder<PreparedSQLUpdateBatchAction<Integer>> createReplaceBatch() { default @NotNull ReplaceBuilder<PreparedBatchUpdateAction<Integer>> createReplaceBatch() {
return Optional.ofNullable(getSQLManager()).map(this::createReplaceBatch) return Optional.ofNullable(getSQLManager()).map(this::createReplaceBatch)
.orElseThrow(() -> new NullPointerException("This table doesn't have a SQLManger.")); .orElseThrow(() -> new NullPointerException("This table doesn't have a SQLManger."));
} }
default @NotNull ReplaceBuilder<PreparedSQLUpdateBatchAction<Integer>> createReplaceBatch(@NotNull SQLManager sqlManager) { default @NotNull ReplaceBuilder<PreparedBatchUpdateAction<Integer>> createReplaceBatch(@NotNull SQLManager sqlManager) {
return sqlManager.createReplaceBatch(getTableName()); return sqlManager.createReplaceBatch(getTableName());
} }

View File

@ -1,11 +1,20 @@
package cc.carm.lib.easysql.api.transaction; package cc.carm.lib.easysql.api.transaction;
import cc.carm.lib.easysql.api.SQLOperator; import cc.carm.lib.easysql.api.SQLManager;
import cc.carm.lib.easysql.api.action.base.PreparedBatchUpdateAction;
import cc.carm.lib.easysql.api.action.base.PreparedUpdateAction;
import cc.carm.lib.easysql.api.action.base.BatchUpdateAction;
import cc.carm.lib.easysql.api.action.base.UpdateAction;
import cc.carm.lib.easysql.api.builder.*;
import cc.carm.lib.easysql.api.enums.IsolationLevel; import cc.carm.lib.easysql.api.enums.IsolationLevel;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
public interface SQLTransaction extends SQLOperator, AutoCloseable { import java.util.List;
public interface SQLTransaction extends AutoCloseable {
@NotNull SQLManager getManager();
/** /**
* 得到本次事务的隔离级别 * 得到本次事务的隔离级别
@ -41,4 +50,108 @@ public interface SQLTransaction extends SQLOperator, AutoCloseable {
*/ */
void rollback(@Nullable SQLSavepoint savepoint); void rollback(@Nullable SQLSavepoint savepoint);
/**
* 执行一条不需要返回结果的SQL语句(多用于UPDATEREPLACEDELETE方法)
* 该方法使用 Statement 实现请注意SQL注入风险
*
* @param sql SQL语句内容
* @return 更新的行数
* @see UpdateAction
*/
@Nullable Integer executeSQL(String sql);
/**
* 执行一条不需要返回结果的预处理SQL更改(UPDATEREPLACEDELETE)
*
* @param sql SQL语句内容
* @param params SQL语句中 ? 的对应参数
* @return 更新的行数
* @see PreparedUpdateAction
*/
@Nullable Integer executeSQL(String sql, Object[] params);
/**
* 执行多条不需要返回结果的SQL更改(UPDATEREPLACEDELETE)
*
* @param sql SQL语句内容
* @param paramsBatch SQL语句中对应?的参数组
* @return 对应参数返回的行数
* @see PreparedBatchUpdateAction
*/
@Nullable List<Integer> executeSQLBatch(String sql, Iterable<Object[]> paramsBatch);
/**
* 执行多条不需要返回结果的SQL
* 该方法使用 Statement 实现请注意SQL注入风险
*
* @param sql SQL语句内容
* @param moreSQL 更多SQL语句内容
* @return 对应参数返回的行数
* @see BatchUpdateAction
*/
@Nullable List<Integer> executeSQLBatch(@NotNull String sql, String... moreSQL);
/**
* 执行多条不需要返回结果的SQL
*
* @param sqlBatch SQL语句内容
* @return 对应参数返回的行数
*/
@Nullable List<Integer> executeSQLBatch(@NotNull Iterable<String> sqlBatch);
/**
* 新建一个查询
*
* @return {@link QueryBuilder}
*/
@NotNull QueryBuilder createQuery();
/**
* 创建一条插入操作
*
* @param tableName 目标表名
* @return {@link InsertBuilder}
*/
@NotNull InsertBuilder<PreparedUpdateAction<Integer>> insertInto(@NotNull String tableName);
/**
* 创建支持多组数据的插入操作
*
* @param tableName 目标表名
* @return {@link InsertBuilder}
*/
@NotNull InsertBuilder<PreparedBatchUpdateAction<Integer>> insertBatchInto(@NotNull String tableName);
/**
* 创建一条替换操作
*
* @param tableName 目标表名
* @return {@link ReplaceBuilder}
*/
@NotNull ReplaceBuilder<PreparedUpdateAction<Integer>> replaceInto(@NotNull String tableName);
/**
* 创建支持多组数据的替换操作
*
* @param tableName 目标表名
* @return {@link ReplaceBuilder}
*/
@NotNull ReplaceBuilder<PreparedBatchUpdateAction<Integer>> replaceBatchInto(@NotNull String tableName);
/**
* 创建更新操作
*
* @param tableName 目标表名
* @return {@link UpdateBuilder}
*/
@NotNull UpdateBuilder updateInto(@NotNull String tableName);
/**
* 创建删除操作
*
* @param tableName 目标表名
* @return {@link DeleteBuilder}
*/
@NotNull DeleteBuilder deleteFrom(@NotNull String tableName);
} }

View File

@ -0,0 +1,15 @@
package cc.carm.lib.easysql.api.transaction;
import cc.carm.lib.easysql.api.action.SQLAction;
import cc.carm.lib.easysql.api.old.SQLSource;
import org.jetbrains.annotations.NotNull;
public interface TransactionAction<T> extends SQLAction<T> {
@NotNull SQLTransaction getTransaction();
default @NotNull SQLSource getSource() {
return getTransaction().getManager();
}
}

View File

@ -1,4 +1,3 @@
import cc.carm.lib.easysql.api.SQLManager;
import cc.carm.lib.easysql.api.table.SQLTable; import cc.carm.lib.easysql.api.table.SQLTable;
import cc.carm.lib.easysql.api.enums.IndexType; import cc.carm.lib.easysql.api.enums.IndexType;
import cc.carm.lib.easysql.api.enums.NumberType; import cc.carm.lib.easysql.api.enums.NumberType;

View File

@ -1,4 +1,3 @@
import cc.carm.lib.easysql.api.SQLManager;
import cc.carm.lib.easysql.api.table.SQLTable; import cc.carm.lib.easysql.api.table.SQLTable;
import cc.carm.lib.easysql.api.builder.TableCreateBuilder; import cc.carm.lib.easysql.api.builder.TableCreateBuilder;
import cc.carm.lib.easysql.api.enums.IndexType; import cc.carm.lib.easysql.api.enums.IndexType;

View File

@ -1,4 +1,3 @@
import cc.carm.lib.easysql.api.SQLManager;
import cc.carm.lib.easysql.api.SQLQuery; import cc.carm.lib.easysql.api.SQLQuery;
import cc.carm.lib.easysql.api.table.SQLTable; import cc.carm.lib.easysql.api.table.SQLTable;
import cc.carm.lib.easysql.api.enums.ForeignKeyRule; import cc.carm.lib.easysql.api.enums.ForeignKeyRule;

View File

@ -1,6 +1,5 @@
package cc.carm.lib.easysql; package cc.carm.lib.easysql;
import cc.carm.lib.easysql.api.SQLManager;
import cc.carm.lib.easysql.manager.SQLManagerImpl; import cc.carm.lib.easysql.manager.SQLManagerImpl;
import cc.carm.lib.easysql.tests.*; import cc.carm.lib.easysql.tests.*;
import com.zaxxer.hikari.HikariConfig; import com.zaxxer.hikari.HikariConfig;

View File

@ -1,6 +1,5 @@
package cc.carm.lib.easysql; package cc.carm.lib.easysql;
import cc.carm.lib.easysql.api.SQLManager;
import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;

View File

@ -1,7 +1,6 @@
package cc.carm.lib.easysql.tests; package cc.carm.lib.easysql.tests;
import cc.carm.lib.easysql.TestHandler; import cc.carm.lib.easysql.TestHandler;
import cc.carm.lib.easysql.api.SQLManager;
import java.sql.SQLException; import java.sql.SQLException;

View File

@ -1,7 +1,6 @@
package cc.carm.lib.easysql.tests; package cc.carm.lib.easysql.tests;
import cc.carm.lib.easysql.TestHandler; import cc.carm.lib.easysql.TestHandler;
import cc.carm.lib.easysql.api.SQLManager;
import java.sql.SQLException; import java.sql.SQLException;

View File

@ -1,7 +1,6 @@
package cc.carm.lib.easysql.tests; package cc.carm.lib.easysql.tests;
import cc.carm.lib.easysql.TestHandler; import cc.carm.lib.easysql.TestHandler;
import cc.carm.lib.easysql.api.SQLManager;
import cc.carm.lib.easysql.api.SQLQuery; import cc.carm.lib.easysql.api.SQLQuery;
import java.math.BigInteger; import java.math.BigInteger;

View File

@ -1,7 +1,6 @@
package cc.carm.lib.easysql.tests; package cc.carm.lib.easysql.tests;
import cc.carm.lib.easysql.TestHandler; import cc.carm.lib.easysql.TestHandler;
import cc.carm.lib.easysql.api.SQLManager;
import java.sql.SQLException; import java.sql.SQLException;

View File

@ -1,7 +1,6 @@
package cc.carm.lib.easysql.tests; package cc.carm.lib.easysql.tests;
import cc.carm.lib.easysql.TestHandler; import cc.carm.lib.easysql.TestHandler;
import cc.carm.lib.easysql.api.SQLManager;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;

View File

@ -1,7 +1,6 @@
package cc.carm.lib.easysql.tests; package cc.carm.lib.easysql.tests;
import cc.carm.lib.easysql.TestHandler; import cc.carm.lib.easysql.TestHandler;
import cc.carm.lib.easysql.api.SQLManager;
import cc.carm.lib.easysql.api.SQLQuery; import cc.carm.lib.easysql.api.SQLQuery;
import java.sql.ResultSet; import java.sql.ResultSet;

View File

@ -1,7 +1,6 @@
package cc.carm.lib.easysql.tests; package cc.carm.lib.easysql.tests;
import cc.carm.lib.easysql.TestHandler; import cc.carm.lib.easysql.TestHandler;
import cc.carm.lib.easysql.api.SQLManager;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Arrays; import java.util.Arrays;

View File

@ -1,7 +1,5 @@
package cc.carm.lib.easysql.tests; package cc.carm.lib.easysql.tests;
import cc.carm.lib.easysql.api.SQLManager;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;

View File

@ -1,7 +1,6 @@
package cc.carm.lib.easysql.tests; package cc.carm.lib.easysql.tests;
import cc.carm.lib.easysql.TestHandler; import cc.carm.lib.easysql.TestHandler;
import cc.carm.lib.easysql.api.SQLManager;
import cc.carm.lib.easysql.api.enums.NumberType; import cc.carm.lib.easysql.api.enums.NumberType;
import java.sql.SQLException; import java.sql.SQLException;

View File

@ -1,7 +1,6 @@
package cc.carm.lib.easysql.tests; package cc.carm.lib.easysql.tests;
import cc.carm.lib.easysql.TestHandler; import cc.carm.lib.easysql.TestHandler;
import cc.carm.lib.easysql.api.SQLManager;
import cc.carm.lib.easysql.api.enums.ForeignKeyRule; import cc.carm.lib.easysql.api.enums.ForeignKeyRule;
import cc.carm.lib.easysql.api.enums.IndexType; import cc.carm.lib.easysql.api.enums.IndexType;

View File

@ -1,7 +1,6 @@
package cc.carm.lib.easysql.tests; package cc.carm.lib.easysql.tests;
import cc.carm.lib.easysql.TestHandler; import cc.carm.lib.easysql.TestHandler;
import cc.carm.lib.easysql.api.SQLManager;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;

View File

@ -1,7 +1,6 @@
package cc.carm.lib.easysql.tests; package cc.carm.lib.easysql.tests;
import cc.carm.lib.easysql.TestHandler; import cc.carm.lib.easysql.TestHandler;
import cc.carm.lib.easysql.api.SQLManager;
import java.sql.SQLException; import java.sql.SQLException;

View File

@ -1,6 +1,5 @@
package cc.carm.lib.easysql.action; package cc.carm.lib.easysql.action;
import cc.carm.lib.easysql.api.SQLAction;
import cc.carm.lib.easysql.api.function.SQLExceptionHandler; import cc.carm.lib.easysql.api.function.SQLExceptionHandler;
import cc.carm.lib.easysql.api.function.SQLFunction; import cc.carm.lib.easysql.api.function.SQLFunction;
import cc.carm.lib.easysql.api.function.SQLHandler; import cc.carm.lib.easysql.api.function.SQLHandler;

View File

@ -1,6 +1,6 @@
package cc.carm.lib.easysql.action; package cc.carm.lib.easysql.action;
import cc.carm.lib.easysql.api.action.SQLUpdateBatchAction; import cc.carm.lib.easysql.api.action.base.BatchUpdateAction;
import cc.carm.lib.easysql.manager.SQLManagerImpl; import cc.carm.lib.easysql.manager.SQLManagerImpl;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -13,13 +13,13 @@ import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class SQLUpdateBatchActionImpl public class BatchUpdateActionImpl
extends AbstractSQLAction<List<Integer>> extends AbstractSQLAction<List<Integer>>
implements SQLUpdateBatchAction { implements BatchUpdateAction {
protected final List<String> sqlContents = new ArrayList<>(); protected final List<String> sqlContents = new ArrayList<>();
public SQLUpdateBatchActionImpl(@NotNull SQLManagerImpl manager, @NotNull String sql) { public BatchUpdateActionImpl(@NotNull SQLManagerImpl manager, @NotNull String sql) {
super(manager, sql); super(manager, sql);
this.sqlContents.add(sql); this.sqlContents.add(sql);
} }
@ -30,7 +30,7 @@ public class SQLUpdateBatchActionImpl
} }
@Override @Override
public SQLUpdateBatchAction addBatch(@NotNull String sql) { public BatchUpdateAction addBatch(@NotNull String sql) {
Objects.requireNonNull(sql, "sql could not be null"); Objects.requireNonNull(sql, "sql could not be null");
this.sqlContents.add(sql); this.sqlContents.add(sql);
return this; return this;

View File

@ -1,6 +1,6 @@
package cc.carm.lib.easysql.action; package cc.carm.lib.easysql.action;
import cc.carm.lib.easysql.api.action.PreparedSQLUpdateBatchAction; import cc.carm.lib.easysql.api.action.base.PreparedBatchUpdateAction;
import cc.carm.lib.easysql.manager.SQLManagerImpl; import cc.carm.lib.easysql.manager.SQLManagerImpl;
import cc.carm.lib.easysql.util.StatementUtil; import cc.carm.lib.easysql.util.StatementUtil;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -15,30 +15,30 @@ import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class PreparedSQLBatchUpdateActionImpl<T extends Number> public class PreparedBatchUpdateActionImpl<T extends Number>
extends AbstractSQLAction<List<T>> extends AbstractSQLAction<List<T>>
implements PreparedSQLUpdateBatchAction<T> { implements PreparedBatchUpdateAction<T> {
boolean returnKeys = false; boolean returnKeys = false;
@NotNull List<Object[]> allParams = new ArrayList<>(); @NotNull List<Object[]> allParams = new ArrayList<>();
protected final @NotNull Class<T> numberClass; protected final @NotNull Class<T> numberClass;
public PreparedSQLBatchUpdateActionImpl(@NotNull SQLManagerImpl manager, @NotNull Class<T> numberClass, public PreparedBatchUpdateActionImpl(@NotNull SQLManagerImpl manager, @NotNull Class<T> numberClass,
@NotNull String sql) { @NotNull String sql) {
super(manager, sql); super(manager, sql);
this.numberClass = numberClass; this.numberClass = numberClass;
this.allParams = new ArrayList<>(); this.allParams = new ArrayList<>();
} }
public PreparedSQLBatchUpdateActionImpl(@NotNull SQLManagerImpl manager, @NotNull Class<T> numberClass, public PreparedBatchUpdateActionImpl(@NotNull SQLManagerImpl manager, @NotNull Class<T> numberClass,
@NotNull UUID uuid, @NotNull String sql) { @NotNull UUID uuid, @NotNull String sql) {
super(manager, sql, uuid); super(manager, sql, uuid);
this.numberClass = numberClass; this.numberClass = numberClass;
} }
@Override @Override
public PreparedSQLBatchUpdateActionImpl<T> allValues(Iterable<Object[]> allValues) { public PreparedBatchUpdateActionImpl<T> allValues(Iterable<Object[]> allValues) {
List<Object[]> paramsList = new ArrayList<>(); List<Object[]> paramsList = new ArrayList<>();
allValues.forEach(paramsList::add); allValues.forEach(paramsList::add);
this.allParams = paramsList; this.allParams = paramsList;
@ -46,20 +46,20 @@ public class PreparedSQLBatchUpdateActionImpl<T extends Number>
} }
@Override @Override
public PreparedSQLBatchUpdateActionImpl<T> values(Object... values) { public PreparedBatchUpdateActionImpl<T> values(Object... values) {
this.allParams.add(values); this.allParams.add(values);
return this; return this;
} }
@Override @Override
public PreparedSQLBatchUpdateActionImpl<T> returnGeneratedKeys() { public PreparedBatchUpdateActionImpl<T> returnGeneratedKeys() {
this.returnKeys = true; this.returnKeys = true;
return this; return this;
} }
@Override @Override
public <N extends Number> PreparedSQLBatchUpdateActionImpl<N> returnGeneratedKeys(Class<N> keyTypeClass) { public <N extends Number> PreparedBatchUpdateActionImpl<N> returnGeneratedKeys(Class<N> keyTypeClass) {
return new PreparedSQLBatchUpdateActionImpl<>(getManager(), keyTypeClass, getActionUUID(), getSQLContent()) return new PreparedBatchUpdateActionImpl<>(getManager(), keyTypeClass, getActionUUID(), getSQLContent())
.allValues(allParams).returnGeneratedKeys(); .allValues(allParams).returnGeneratedKeys();
} }

View File

@ -1,7 +1,7 @@
package cc.carm.lib.easysql.action; package cc.carm.lib.easysql.action;
import cc.carm.lib.easysql.api.action.PreparedSQLUpdateAction; import cc.carm.lib.easysql.api.action.base.PreparedUpdateAction;
import cc.carm.lib.easysql.api.action.SQLUpdateAction; import cc.carm.lib.easysql.api.action.base.UpdateAction;
import cc.carm.lib.easysql.manager.SQLManagerImpl; import cc.carm.lib.easysql.manager.SQLManagerImpl;
import cc.carm.lib.easysql.util.StatementUtil; import cc.carm.lib.easysql.util.StatementUtil;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -16,43 +16,43 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
public class PreparedSQLUpdateActionImpl<T extends Number> public class PreparedUpdateActionImpl<T extends Number>
extends SQLUpdateActionImpl<T> extends UpdateActionImpl<T>
implements PreparedSQLUpdateAction<T> { implements PreparedUpdateAction<T> {
Object[] params; Object[] params;
public PreparedSQLUpdateActionImpl(@NotNull SQLManagerImpl manager, @NotNull Class<T> numberClass, public PreparedUpdateActionImpl(@NotNull SQLManagerImpl manager, @NotNull Class<T> numberClass,
@NotNull String sql) { @NotNull String sql) {
this(manager, numberClass, sql, (Object[]) null); this(manager, numberClass, sql, (Object[]) null);
} }
public PreparedSQLUpdateActionImpl(@NotNull SQLManagerImpl manager, @NotNull Class<T> numberClass, public PreparedUpdateActionImpl(@NotNull SQLManagerImpl manager, @NotNull Class<T> numberClass,
@NotNull String sql, @Nullable List<Object> params) { @NotNull String sql, @Nullable List<Object> params) {
this(manager, numberClass, sql, params == null ? null : params.toArray()); this(manager, numberClass, sql, params == null ? null : params.toArray());
} }
public PreparedSQLUpdateActionImpl(@NotNull SQLManagerImpl manager, @NotNull Class<T> numberClass, public PreparedUpdateActionImpl(@NotNull SQLManagerImpl manager, @NotNull Class<T> numberClass,
@NotNull String sql, @Nullable Object[] params) { @NotNull String sql, @Nullable Object[] params) {
super(manager, numberClass, sql); super(manager, numberClass, sql);
this.params = params; this.params = params;
} }
public PreparedSQLUpdateActionImpl(@NotNull SQLManagerImpl manager, @NotNull Class<T> numberClass, public PreparedUpdateActionImpl(@NotNull SQLManagerImpl manager, @NotNull Class<T> numberClass,
@NotNull UUID uuid, @NotNull String sql, @NotNull UUID uuid, @NotNull String sql,
Object[] params) { Object[] params) {
super(manager, numberClass, uuid, sql); super(manager, numberClass, uuid, sql);
this.params = params; this.params = params;
} }
@Override @Override
public PreparedSQLUpdateActionImpl<T> values(Object... params) { public PreparedUpdateActionImpl<T> values(Object... params) {
this.params = params; this.params = params;
return this; return this;
} }
@Override @Override
public PreparedSQLUpdateActionImpl<T> values(@Nullable Iterable<Object> params) { public PreparedUpdateActionImpl<T> values(@Nullable Iterable<Object> params) {
if (params == null) { if (params == null) {
return values((Object[]) null); return values((Object[]) null);
} else { } else {
@ -86,8 +86,8 @@ public class PreparedSQLUpdateActionImpl<T extends Number>
} }
@Override @Override
public <N extends Number> SQLUpdateAction<N> returnGeneratedKey(Class<N> keyTypeClass) { public <N extends Number> UpdateAction<N> returnGeneratedKey(Class<N> keyTypeClass) {
PreparedSQLUpdateActionImpl<N> newAction = new PreparedSQLUpdateActionImpl<>(getManager(), keyTypeClass, getActionUUID(), getSQLContent(), params); PreparedUpdateActionImpl<N> newAction = new PreparedUpdateActionImpl<>(getManager(), keyTypeClass, getActionUUID(), getSQLContent(), params);
newAction.returnGeneratedKey(); newAction.returnGeneratedKey();
return newAction; return newAction;
} }

View File

@ -1,6 +1,6 @@
package cc.carm.lib.easysql.action; package cc.carm.lib.easysql.action;
import cc.carm.lib.easysql.api.action.SQLUpdateAction; import cc.carm.lib.easysql.api.action.base.UpdateAction;
import cc.carm.lib.easysql.manager.SQLManagerImpl; import cc.carm.lib.easysql.manager.SQLManagerImpl;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -11,22 +11,22 @@ import java.sql.Statement;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.UUID; import java.util.UUID;
public class SQLUpdateActionImpl<T extends Number> public class UpdateActionImpl<T extends Number>
extends AbstractSQLAction<T> extends AbstractSQLAction<T>
implements SQLUpdateAction<T> { implements UpdateAction<T> {
protected final @NotNull Class<T> numberClass; protected final @NotNull Class<T> numberClass;
protected boolean returnGeneratedKeys = false; protected boolean returnGeneratedKeys = false;
public SQLUpdateActionImpl(@NotNull SQLManagerImpl manager, @NotNull Class<T> numberClass, public UpdateActionImpl(@NotNull SQLManagerImpl manager, @NotNull Class<T> numberClass,
@NotNull String sql) { @NotNull String sql) {
super(manager, sql); super(manager, sql);
this.numberClass = numberClass; this.numberClass = numberClass;
} }
public SQLUpdateActionImpl(@NotNull SQLManagerImpl manager, @NotNull Class<T> numberClass, public UpdateActionImpl(@NotNull SQLManagerImpl manager, @NotNull Class<T> numberClass,
@NotNull UUID uuid, @NotNull String sql) { @NotNull UUID uuid, @NotNull String sql) {
super(manager, sql, uuid); super(manager, sql, uuid);
this.numberClass = numberClass; this.numberClass = numberClass;
} }
@ -52,14 +52,14 @@ public class SQLUpdateActionImpl<T extends Number>
} }
@Override @Override
public SQLUpdateAction<T> returnGeneratedKey() { public UpdateAction<T> returnGeneratedKey() {
this.returnGeneratedKeys = true; this.returnGeneratedKeys = true;
return this; return this;
} }
@Override @Override
public <N extends Number> SQLUpdateAction<N> returnGeneratedKey(Class<N> keyTypeClass) { public <N extends Number> UpdateAction<N> returnGeneratedKey(Class<N> keyTypeClass) {
return new SQLUpdateActionImpl<>(getManager(), keyTypeClass, getActionUUID(), getSQLContent()).returnGeneratedKey(); return new UpdateActionImpl<>(getManager(), keyTypeClass, getActionUUID(), getSQLContent()).returnGeneratedKey();
} }
} }

View File

@ -1,6 +1,5 @@
package cc.carm.lib.easysql.builder.impl; package cc.carm.lib.easysql.builder.impl;
import cc.carm.lib.easysql.api.SQLAction;
import cc.carm.lib.easysql.api.builder.ConditionalBuilder; import cc.carm.lib.easysql.api.builder.ConditionalBuilder;
import cc.carm.lib.easysql.builder.AbstractSQLBuilder; import cc.carm.lib.easysql.builder.AbstractSQLBuilder;
import cc.carm.lib.easysql.manager.SQLManagerImpl; import cc.carm.lib.easysql.manager.SQLManagerImpl;

View File

@ -1,8 +1,7 @@
package cc.carm.lib.easysql.builder.impl; package cc.carm.lib.easysql.builder.impl;
import cc.carm.lib.easysql.action.PreparedSQLUpdateActionImpl; import cc.carm.lib.easysql.action.PreparedUpdateActionImpl;
import cc.carm.lib.easysql.api.SQLAction; import cc.carm.lib.easysql.api.action.base.PreparedUpdateAction;
import cc.carm.lib.easysql.api.action.PreparedSQLUpdateAction;
import cc.carm.lib.easysql.api.builder.DeleteBuilder; import cc.carm.lib.easysql.api.builder.DeleteBuilder;
import cc.carm.lib.easysql.manager.SQLManagerImpl; import cc.carm.lib.easysql.manager.SQLManagerImpl;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -24,7 +23,7 @@ public class DeleteBuilderImpl
} }
@Override @Override
public PreparedSQLUpdateAction<Integer> build() { public PreparedUpdateAction<Integer> build() {
StringBuilder sqlBuilder = new StringBuilder(); StringBuilder sqlBuilder = new StringBuilder();
@ -33,7 +32,7 @@ public class DeleteBuilderImpl
if (hasConditions()) sqlBuilder.append(" ").append(buildConditionSQL()); if (hasConditions()) sqlBuilder.append(" ").append(buildConditionSQL());
if (limit > 0) sqlBuilder.append(" ").append(buildLimitSQL()); if (limit > 0) sqlBuilder.append(" ").append(buildLimitSQL());
return new PreparedSQLUpdateActionImpl<>( return new PreparedUpdateActionImpl<>(
getManager(), Integer.class, sqlBuilder.toString(), getManager(), Integer.class, sqlBuilder.toString(),
(hasConditionParams() ? getConditionParams() : null) (hasConditionParams() ? getConditionParams() : null)
); );

View File

@ -1,6 +1,5 @@
package cc.carm.lib.easysql.builder.impl; package cc.carm.lib.easysql.builder.impl;
import cc.carm.lib.easysql.api.SQLAction;
import cc.carm.lib.easysql.api.builder.InsertBuilder; import cc.carm.lib.easysql.api.builder.InsertBuilder;
import cc.carm.lib.easysql.builder.AbstractSQLBuilder; import cc.carm.lib.easysql.builder.AbstractSQLBuilder;
import cc.carm.lib.easysql.manager.SQLManagerImpl; import cc.carm.lib.easysql.manager.SQLManagerImpl;

View File

@ -10,8 +10,6 @@ import cc.carm.lib.easysql.builder.AbstractSQLBuilder;
import cc.carm.lib.easysql.manager.SQLManagerImpl; import cc.carm.lib.easysql.manager.SQLManagerImpl;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Objects; import java.util.Objects;
public class QueryBuilderImpl extends AbstractSQLBuilder implements QueryBuilder { public class QueryBuilderImpl extends AbstractSQLBuilder implements QueryBuilder {

View File

@ -1,6 +1,5 @@
package cc.carm.lib.easysql.builder.impl; package cc.carm.lib.easysql.builder.impl;
import cc.carm.lib.easysql.api.SQLAction;
import cc.carm.lib.easysql.api.builder.ReplaceBuilder; import cc.carm.lib.easysql.api.builder.ReplaceBuilder;
import cc.carm.lib.easysql.builder.AbstractSQLBuilder; import cc.carm.lib.easysql.builder.AbstractSQLBuilder;
import cc.carm.lib.easysql.manager.SQLManagerImpl; import cc.carm.lib.easysql.manager.SQLManagerImpl;

View File

@ -1,7 +1,6 @@
package cc.carm.lib.easysql.builder.impl; package cc.carm.lib.easysql.builder.impl;
import cc.carm.lib.easysql.action.SQLUpdateActionImpl; import cc.carm.lib.easysql.action.UpdateActionImpl;
import cc.carm.lib.easysql.api.SQLAction;
import cc.carm.lib.easysql.api.builder.TableAlterBuilder; import cc.carm.lib.easysql.api.builder.TableAlterBuilder;
import cc.carm.lib.easysql.api.enums.IndexType; import cc.carm.lib.easysql.api.enums.IndexType;
import cc.carm.lib.easysql.builder.AbstractSQLBuilder; import cc.carm.lib.easysql.builder.AbstractSQLBuilder;
@ -141,7 +140,7 @@ public class TableAlterBuilderImpl extends AbstractSQLBuilder implements TableAl
); );
} }
private SQLUpdateActionImpl<Integer> createAction(@NotNull String sql) { private UpdateActionImpl<Integer> createAction(@NotNull String sql) {
return new SQLUpdateActionImpl<>(getManager(), Integer.class, sql); return new UpdateActionImpl<>(getManager(), Integer.class, sql);
} }
} }

View File

@ -1,7 +1,7 @@
package cc.carm.lib.easysql.builder.impl; package cc.carm.lib.easysql.builder.impl;
import cc.carm.lib.easysql.action.SQLUpdateActionImpl; import cc.carm.lib.easysql.action.UpdateActionImpl;
import cc.carm.lib.easysql.api.action.SQLUpdateAction; import cc.carm.lib.easysql.api.action.base.UpdateAction;
import cc.carm.lib.easysql.api.builder.TableCreateBuilder; import cc.carm.lib.easysql.api.builder.TableCreateBuilder;
import cc.carm.lib.easysql.api.enums.ForeignKeyRule; import cc.carm.lib.easysql.api.enums.ForeignKeyRule;
import cc.carm.lib.easysql.api.enums.IndexType; import cc.carm.lib.easysql.api.enums.IndexType;
@ -75,7 +75,7 @@ public class TableCreateBuilderImpl extends AbstractSQLBuilder implements TableC
} }
@Override @Override
public SQLUpdateAction<Integer> build() { public UpdateAction<Integer> build() {
StringBuilder createSQL = new StringBuilder(); StringBuilder createSQL = new StringBuilder();
createSQL.append("CREATE TABLE IF NOT EXISTS ").append(withBackQuote(tableName)); createSQL.append("CREATE TABLE IF NOT EXISTS ").append(withBackQuote(tableName));
createSQL.append("("); createSQL.append("(");
@ -94,7 +94,7 @@ public class TableCreateBuilderImpl extends AbstractSQLBuilder implements TableC
createSQL.append(" COMMENT ").append(withQuote(tableComment)); createSQL.append(" COMMENT ").append(withQuote(tableComment));
} }
return new SQLUpdateActionImpl<>(getManager(), Integer.class, createSQL.toString()); return new UpdateActionImpl<>(getManager(), Integer.class, createSQL.toString());
} }
@Override @Override

View File

@ -1,8 +1,7 @@
package cc.carm.lib.easysql.builder.impl; package cc.carm.lib.easysql.builder.impl;
import cc.carm.lib.easysql.action.PreparedSQLUpdateActionImpl; import cc.carm.lib.easysql.action.PreparedUpdateActionImpl;
import cc.carm.lib.easysql.api.SQLAction; import cc.carm.lib.easysql.api.action.base.PreparedUpdateAction;
import cc.carm.lib.easysql.api.action.PreparedSQLUpdateAction;
import cc.carm.lib.easysql.api.builder.UpdateBuilder; import cc.carm.lib.easysql.api.builder.UpdateBuilder;
import cc.carm.lib.easysql.manager.SQLManagerImpl; import cc.carm.lib.easysql.manager.SQLManagerImpl;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -27,7 +26,7 @@ public class UpdateBuilderImpl
} }
@Override @Override
public PreparedSQLUpdateAction<Integer> build() { public PreparedUpdateAction<Integer> build() {
StringBuilder sqlBuilder = new StringBuilder(); StringBuilder sqlBuilder = new StringBuilder();
@ -47,7 +46,7 @@ public class UpdateBuilderImpl
if (limit > 0) sqlBuilder.append(" ").append(buildLimitSQL()); if (limit > 0) sqlBuilder.append(" ").append(buildLimitSQL());
return new PreparedSQLUpdateActionImpl<>(getManager(), Integer.class, sqlBuilder.toString(), allParams); return new PreparedUpdateActionImpl<>(getManager(), Integer.class, sqlBuilder.toString(), allParams);
} }
@Override @Override

View File

@ -1,14 +1,13 @@
package cc.carm.lib.easysql.manager; package cc.carm.lib.easysql.manager;
import cc.carm.lib.easysql.action.PreparedSQLBatchUpdateActionImpl; import cc.carm.lib.easysql.action.PreparedBatchUpdateActionImpl;
import cc.carm.lib.easysql.action.PreparedSQLUpdateActionImpl; import cc.carm.lib.easysql.action.PreparedUpdateActionImpl;
import cc.carm.lib.easysql.action.SQLUpdateActionImpl; import cc.carm.lib.easysql.action.UpdateActionImpl;
import cc.carm.lib.easysql.action.SQLUpdateBatchActionImpl; import cc.carm.lib.easysql.action.BatchUpdateActionImpl;
import cc.carm.lib.easysql.api.SQLManager;
import cc.carm.lib.easysql.api.SQLQuery; import cc.carm.lib.easysql.api.SQLQuery;
import cc.carm.lib.easysql.api.action.PreparedSQLUpdateAction; import cc.carm.lib.easysql.api.action.base.PreparedUpdateAction;
import cc.carm.lib.easysql.api.action.PreparedSQLUpdateBatchAction; import cc.carm.lib.easysql.api.action.base.PreparedBatchUpdateAction;
import cc.carm.lib.easysql.api.action.SQLUpdateBatchAction; import cc.carm.lib.easysql.api.action.base.BatchUpdateAction;
import cc.carm.lib.easysql.api.builder.*; import cc.carm.lib.easysql.api.builder.*;
import cc.carm.lib.easysql.api.function.SQLBiFunction; import cc.carm.lib.easysql.api.function.SQLBiFunction;
import cc.carm.lib.easysql.api.function.SQLDebugHandler; import cc.carm.lib.easysql.api.function.SQLDebugHandler;
@ -120,22 +119,22 @@ public class SQLManagerImpl implements SQLManager {
@Override @Override
public Integer executeSQL(String sql) { public Integer executeSQL(String sql) {
return new SQLUpdateActionImpl<>(this, Integer.class, sql).execute(null); return new UpdateActionImpl<>(this, Integer.class, sql).execute(null);
} }
@Override @Override
public Integer executeSQL(String sql, Object[] params) { public Integer executeSQL(String sql, Object[] params) {
return new PreparedSQLUpdateActionImpl<>(this, Integer.class, sql, params).execute(null); return new PreparedUpdateActionImpl<>(this, Integer.class, sql, params).execute(null);
} }
@Override @Override
public List<Integer> executeSQLBatch(String sql, Iterable<Object[]> paramsBatch) { public List<Integer> executeSQLBatch(String sql, Iterable<Object[]> paramsBatch) {
return new PreparedSQLBatchUpdateActionImpl<>(this, Integer.class, sql).allValues(paramsBatch).execute(null); return new PreparedBatchUpdateActionImpl<>(this, Integer.class, sql).allValues(paramsBatch).execute(null);
} }
@Override @Override
public List<Integer> executeSQLBatch(@NotNull String sql, String... moreSQL) { public List<Integer> executeSQLBatch(@NotNull String sql, String... moreSQL) {
SQLUpdateBatchAction action = new SQLUpdateBatchActionImpl(this, sql); BatchUpdateAction action = new BatchUpdateActionImpl(this, sql);
if (moreSQL != null && moreSQL.length > 0) { if (moreSQL != null && moreSQL.length > 0) {
Arrays.stream(moreSQL).forEach(action::addBatch); Arrays.stream(moreSQL).forEach(action::addBatch);
} }
@ -147,7 +146,7 @@ public class SQLManagerImpl implements SQLManager {
Iterator<String> iterator = sqlBatch.iterator(); Iterator<String> iterator = sqlBatch.iterator();
if (!iterator.hasNext()) return null; // PLEASE GIVE IT SOMETHING if (!iterator.hasNext()) return null; // PLEASE GIVE IT SOMETHING
SQLUpdateBatchAction action = new SQLUpdateBatchActionImpl(this, iterator.next()); BatchUpdateAction action = new BatchUpdateActionImpl(this, iterator.next());
while (iterator.hasNext()) { while (iterator.hasNext()) {
action.addBatch(iterator.next()); action.addBatch(iterator.next());
} }
@ -200,41 +199,41 @@ public class SQLManagerImpl implements SQLManager {
} }
@Override @Override
public InsertBuilder<PreparedSQLUpdateBatchAction<Integer>> createInsertBatch(@NotNull String tableName) { public InsertBuilder<PreparedBatchUpdateAction<Integer>> createInsertBatch(@NotNull String tableName) {
return new InsertBuilderImpl<PreparedSQLUpdateBatchAction<Integer>>(this, tableName) { return new InsertBuilderImpl<PreparedBatchUpdateAction<Integer>>(this, tableName) {
@Override @Override
public PreparedSQLUpdateBatchAction<Integer> columns(List<String> columnNames) { public PreparedBatchUpdateAction<Integer> columns(List<String> columnNames) {
return new PreparedSQLBatchUpdateActionImpl<>(getManager(), Integer.class, buildSQL(getTableName(), columnNames)); return new PreparedBatchUpdateActionImpl<>(getManager(), Integer.class, buildSQL(getTableName(), columnNames));
} }
}; };
} }
@Override @Override
public InsertBuilder<PreparedSQLUpdateAction<Integer>> insertInto(@NotNull String tableName) { public InsertBuilder<PreparedUpdateAction<Integer>> insertInto(@NotNull String tableName) {
return new InsertBuilderImpl<PreparedSQLUpdateAction<Integer>>(this, tableName) { return new InsertBuilderImpl<PreparedUpdateAction<Integer>>(this, tableName) {
@Override @Override
public PreparedSQLUpdateAction<Integer> columns(List<String> columnNames) { public PreparedUpdateAction<Integer> columns(List<String> columnNames) {
return new PreparedSQLUpdateActionImpl<>(getManager(), Integer.class, buildSQL(getTableName(), columnNames)); return new PreparedUpdateActionImpl<>(getManager(), Integer.class, buildSQL(getTableName(), columnNames));
} }
}; };
} }
@Override @Override
public ReplaceBuilder<PreparedSQLUpdateBatchAction<Integer>> createReplaceBatch(@NotNull String tableName) { public ReplaceBuilder<PreparedBatchUpdateAction<Integer>> createReplaceBatch(@NotNull String tableName) {
return new ReplaceBuilderImpl<PreparedSQLUpdateBatchAction<Integer>>(this, tableName) { return new ReplaceBuilderImpl<PreparedBatchUpdateAction<Integer>>(this, tableName) {
@Override @Override
public PreparedSQLUpdateBatchAction<Integer> columns(List<String> columnNames) { public PreparedBatchUpdateAction<Integer> columns(List<String> columnNames) {
return new PreparedSQLBatchUpdateActionImpl<>(getManager(), Integer.class, buildSQL(getTableName(), columnNames)); return new PreparedBatchUpdateActionImpl<>(getManager(), Integer.class, buildSQL(getTableName(), columnNames));
} }
}; };
} }
@Override @Override
public ReplaceBuilder<PreparedSQLUpdateAction<Integer>> createReplace(@NotNull String tableName) { public ReplaceBuilder<PreparedUpdateAction<Integer>> createReplace(@NotNull String tableName) {
return new ReplaceBuilderImpl<PreparedSQLUpdateAction<Integer>>(this, tableName) { return new ReplaceBuilderImpl<PreparedUpdateAction<Integer>>(this, tableName) {
@Override @Override
public PreparedSQLUpdateAction<Integer> columns(List<String> columnNames) { public PreparedUpdateAction<Integer> columns(List<String> columnNames) {
return new PreparedSQLUpdateActionImpl<>(getManager(), Integer.class, buildSQL(getTableName(), columnNames)); return new PreparedUpdateActionImpl<>(getManager(), Integer.class, buildSQL(getTableName(), columnNames));
} }
}; };
} }

View File

@ -1,6 +1,5 @@
package cc.carm.lib.easysql; package cc.carm.lib.easysql;
import cc.carm.lib.easysql.api.SQLManager;
import cc.carm.lib.easysql.api.SQLQuery; import cc.carm.lib.easysql.api.SQLQuery;
import cc.carm.lib.easysql.api.util.TimeDateUtils; import cc.carm.lib.easysql.api.util.TimeDateUtils;
import cc.carm.lib.easysql.manager.SQLManagerImpl; import cc.carm.lib.easysql.manager.SQLManagerImpl;

View File

@ -1,6 +1,5 @@
package cc.carm.lib.easysql; package cc.carm.lib.easysql;
import cc.carm.lib.easysql.api.SQLManager;
import cc.carm.lib.easysql.api.SQLQuery; import cc.carm.lib.easysql.api.SQLQuery;
import cc.carm.lib.easysql.api.util.TimeDateUtils; import cc.carm.lib.easysql.api.util.TimeDateUtils;
import cc.carm.lib.easysql.manager.SQLManagerImpl; import cc.carm.lib.easysql.manager.SQLManagerImpl;