mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
fix code
This commit is contained in:
parent
5623081278
commit
a8a8c09ae8
40
hutool-db/README.md
Normal file
40
hutool-db/README.md
Normal file
@ -0,0 +1,40 @@
|
||||
<p align="center">
|
||||
<a href="https://hutool.cn/"><img src="https://plus.hutool.cn/images/hutool.svg" width="45%"></a>
|
||||
</p>
|
||||
<p align="center">
|
||||
<strong>🍬A set of tools that keep Java sweet.</strong>
|
||||
</p>
|
||||
<p align="center">
|
||||
👉 <a href="https://hutool.cn">https://hutool.cn/</a> 👈
|
||||
</p>
|
||||
|
||||
## 📚Hutool-db 模块介绍
|
||||
|
||||
`Hutool-db`是一个在JDBC基础上封装的数据库操作工具类。通过包装,使用ActiveRecord思想操作数据库。
|
||||
在Hutool-db中,使用Entity(本质上是个Map)代替Bean来使数据库操作更加灵活,同时提供Bean和Entity的转换提供传统ORM的兼容支持。
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
## 🛠️包含内容
|
||||
|
||||
### 数据库方言(dialect)
|
||||
通过抽象CRUD方法,针对不同数据库,封装对应的查询、分页等SQL转换功能,入口为`DialectFactory`。
|
||||
|
||||
### 数据源(ds)
|
||||
提供常用数据库连接池的门面支持,支持顺序为:
|
||||
|
||||
- Hikari > Druid > Tomcat > BeeCP > Dbcp > C3p0 > Hutool Pooled
|
||||
|
||||
### SQL相关工具(sql)
|
||||
提供SQL相关功能,包括SQL变量替换(NamedSql),通过对象完成SQL构建(SqlBuilder)等。
|
||||
|
||||
`SqlSqlExecutor`提供SQL执行的静态方法。
|
||||
|
||||
### 数据库元信息(meta)
|
||||
通过`MetaUtil`提供数据库表、字段等信息的读取操作。
|
||||
|
||||
### 增删改查(Db、Session)
|
||||
提供增删改查的汇总方法类。
|
||||
|
||||
### 结果转换(handler)
|
||||
通过封装`RsHandler`,提供将ResultSet转换为需要的对象的功能。
|
@ -498,13 +498,7 @@ public abstract class AbstractDb<R extends AbstractDb<R>> extends DefaultConnect
|
||||
* @throws DbRuntimeException SQL执行异常
|
||||
*/
|
||||
public <T> T find(final Collection<String> fields, final Entity where, final RsHandler<T> rsh) throws DbRuntimeException {
|
||||
Connection conn = null;
|
||||
try {
|
||||
conn = this.getConnection();
|
||||
return runner.find(conn, Query.of(where).setFields(fields), rsh);
|
||||
} finally {
|
||||
this.closeConnection(conn);
|
||||
}
|
||||
return find(Query.of(where).setFields(fields), rsh);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -13,7 +13,12 @@ public class DefaultConnectionHolder implements ConnectionHolder {
|
||||
|
||||
protected final DataSource ds;
|
||||
|
||||
public DefaultConnectionHolder(DataSource ds) {
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
* @param ds {@link DataSource}
|
||||
*/
|
||||
public DefaultConnectionHolder(final DataSource ds) {
|
||||
this.ds = ds;
|
||||
}
|
||||
|
||||
|
@ -118,7 +118,7 @@ public class StatementUtil {
|
||||
*
|
||||
* @param conn 数据库连接
|
||||
* @param sql SQL语句,使用"?"做为占位符
|
||||
* @param params "?"对应参数列表
|
||||
* @param params "?"对应参数列表或者Map表示命名参数
|
||||
* @return {@link PreparedStatement}
|
||||
* @throws SQLException SQL异常
|
||||
* @since 3.2.3
|
||||
|
@ -115,9 +115,18 @@ public class SqlBuilder implements Builder<String> {
|
||||
private QuoteWrapper quoteWrapper;
|
||||
|
||||
// --------------------------------------------------------------- Constructor start
|
||||
|
||||
/**
|
||||
* 构造
|
||||
*/
|
||||
public SqlBuilder() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
* @param quoteWrapper 包装器
|
||||
*/
|
||||
public SqlBuilder(final QuoteWrapper quoteWrapper) {
|
||||
this.quoteWrapper = quoteWrapper;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user