Prepare release

This commit is contained in:
Looly 2020-12-16 00:16:07 +08:00
commit 21c34a6674
5 changed files with 30 additions and 17 deletions

View File

@ -19,6 +19,12 @@ import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
/**
* 提供基于方言的原始增删改查执行封装
*
* @author looly
* @since 5.5.3
*/
public class DialectRunner implements Serializable {
private static final long serialVersionUID = 1L;
@ -47,6 +53,7 @@ public class DialectRunner implements Serializable {
}
//---------------------------------------------------------------------------- CRUD start
/**
* 批量插入数据<br>
* 批量插入必须严格保持Entity的结构一致不一致会导致插入数据出现不可预知的结果<br>
@ -65,7 +72,7 @@ public class DialectRunner implements Serializable {
PreparedStatement ps = null;
try {
if(1 == records.length){
if (1 == records.length) {
//单条单独处理
ps = dialect.psForInsert(conn, records[0]);
return new int[]{ps.executeUpdate()};
@ -83,8 +90,9 @@ public class DialectRunner implements Serializable {
* 插入数据<br>
* 此方法不会关闭Connection
*
* @param conn 数据库连接
* @param record 记录
* @param <T> 主键类型可能为数字或对象列表
* @param conn 数据库连接
* @param record 记录
* @param generatedKeysHandler 自增主键处理器用于定义返回自增主键的范围和类型
* @return 主键列表
* @throws SQLException SQL执行异常
@ -99,7 +107,7 @@ public class DialectRunner implements Serializable {
try {
ps = dialect.psForInsert(conn, record);
ps.executeUpdate();
if(null == generatedKeysHandler){
if (null == generatedKeysHandler) {
return null;
}
return StatementUtil.getGeneratedKeys(ps, generatedKeysHandler);
@ -204,10 +212,10 @@ public class DialectRunner implements Serializable {
* 分页查询<br>
* 此方法不会关闭Connection
*
* @param <T> 结果对象类型
* @param conn 数据库连接对象
* @param <T> 结果对象类型
* @param conn 数据库连接对象
* @param query 查询条件包含表名
* @param rsh 结果集处理对象
* @param rsh 结果集处理对象
* @return 结果对象
* @throws SQLException SQL执行异常
*/

View File

@ -153,7 +153,7 @@ public class SqlConnRunner extends DialectRunner {
* @throws SQLException SQL执行异常
*/
public Long insertForGeneratedKey(Connection conn, Entity record) throws SQLException {
return insert(conn, record, (rs)->{
return insert(conn, record, (rs) -> {
Long generatedKey = null;
if (rs != null && rs.next()) {
try {
@ -281,7 +281,7 @@ public class SqlConnRunner extends DialectRunner {
/**
* 获取查询结果总数生成类似于 SELECT count(1) from (sql)
*
* @param conn 数据库连接对象
* @param conn 数据库连接对象
* @param selectSql 查询语句
* @return 结果数
* @throws SQLException SQL异常
@ -322,7 +322,7 @@ public class SqlConnRunner extends DialectRunner {
*/
public PageResult<Entity> page(Connection conn, SqlBuilder sqlBuilder, Page page) throws SQLException {
final PageResultHandler pageResultHandler = new PageResultHandler(
new PageResult<>(page.getPageNumber(), page.getPageSize(), (int)count(conn, sqlBuilder.build())),
new PageResult<>(page.getPageNumber(), page.getPageSize(), (int) count(conn, sqlBuilder.build())),
this.caseInsensitive);
return page(conn, sqlBuilder, page, pageResultHandler);
}
@ -370,7 +370,7 @@ public class SqlConnRunner extends DialectRunner {
*/
public PageResult<Entity> page(Connection conn, Collection<String> fields, Entity where, Page page) throws SQLException {
final PageResultHandler pageResultHandler = new PageResultHandler(
new PageResult<>(page.getPageNumber(), page.getPageSize(), (int)count(conn, where)),
new PageResult<>(page.getPageNumber(), page.getPageSize(), (int) count(conn, where)),
this.caseInsensitive);
return page(conn, fields, where, page, pageResultHandler);
}
@ -379,10 +379,11 @@ public class SqlConnRunner extends DialectRunner {
* 分页查询<br>
* 此方法不会关闭Connection
*
* @param conn 数据库连接对象
* @param fields 返回的字段列表null则返回所有字段
* @param where 条件实体类包含表名
* @param page 分页对象
* @param <T> 结果类型取决于 {@link RsHandler} 的处理逻辑
* @param conn 数据库连接对象
* @param fields 返回的字段列表null则返回所有字段
* @param where 条件实体类包含表名
* @param page 分页对象
* @param handler 结果集处理器
* @return 结果对象
* @throws SQLException SQL执行异常

View File

@ -98,6 +98,7 @@ public class WordTree extends HashMap<Character, WordTree> {
* 添加单词使用默认类型
*
* @param word 单词
* @return this
*/
public WordTree addWord(String word) {
final Filter<Character> charFilter = this.charFilter;

View File

@ -70,6 +70,7 @@ public class GanymedUtil {
* @param cmd 命令
* @param charset 发送和读取内容的编码
* @param errStream 错误信息输出到的位置
* @return 执行返回结果
*/
public static String exec(Session session, String cmd, Charset charset, OutputStream errStream) {
final String result;
@ -97,6 +98,7 @@ public class GanymedUtil {
* @param cmd 命令
* @param charset 发送和读取内容的编码
* @param errStream 错误信息输出到的位置
* @return 执行返回结果
*/
public static String execByShell(Session session, String cmd, Charset charset, OutputStream errStream) {
final String result;

View File

@ -113,7 +113,7 @@ public class OfdWriter implements Serializable, Closeable {
}
/**
* 增加节点
* 增加节点
*
* @param div 节点可以是段落CanvasImg或者填充
* @return this
@ -124,8 +124,9 @@ public class OfdWriter implements Serializable, Closeable {
}
/**
* 增加节点
* 增加注释比如水印等
*
* @param page 页码
* @param annotation 节点可以是段落CanvasImg或者填充
* @return this
*/