public class NutSql extends NutStatement implements Sql
| 限定符和类型 | 方法和说明 |
|---|---|
void |
addBatch()
将当前的参数列表存储,以便执行批处理
|
void |
clearBatch()
清除所有的曾经设置过的参数
|
Sql |
duplicate() |
ValueAdaptor[] |
getAdaptors()
为本语句每一个参数提供一个适配器
|
Object[][] |
getParamMatrix()
用一个矩阵描述语句的参数表。
|
String |
getSourceSql() |
void |
onAfter(Connection conn,
ResultSet rs)
语句执行完毕的后续操作
这个接口函数你基本不会直接使用的
|
void |
onBefore(Connection conn)
语句执行之前的操作
这个接口函数你基本不会直接使用的
|
VarIndex |
paramIndex() |
VarSet |
params()
所谓"参数",就是当 Sql 对象转换成 PreparedStatement 对象前,会被填充成 ?
|
Sql |
setCallback(SqlCallback callback)
当前 Statement 被执行完毕后,有可能会产生一个 ResultSet。
|
Sql |
setCondition(Condition cnd)
为 SQL 增加条件,SQL 必须有 '$condition' 变量
|
Sql |
setEntity(Entity<?> en)
设置 当前语句对应的实体
|
NutSql |
setPager(Pager pager)
为自定义SQL设置Pager
如果设置为非空值,那么将附加上分页语句!!
|
void |
setSourceSql(String sql) |
void |
setValueAdaptor(String name,
ValueAdaptor adaptor)
手动为某个语句参数设置适配器。
|
String |
toPreparedStatement()
将 Dao 语句转换为 JDBC SQL 缓冲语句
|
String |
toString()
输出打印字符串
|
VarIndex |
varIndex() |
VarSet |
vars()
所谓"变量",就是当 Sql 对象转换成 Statement 对象前,预先被填充的占位符。
|
getBoolean, getContext, getEntity, getInt, getList, getNumber, getObject, getResult, getSqlType, getString, getUpdateCount, isAlter, isCall, isCreate, isDelete, isDrop, isExec, isInsert, isOther, isRun, isSelect, isUpdate, param2String, setContext, setSqlType, toExampleStatement, toStatementclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetBoolean, getContext, getEntity, getInt, getList, getNumber, getObject, getResult, getSqlType, getString, getUpdateCount, isAlter, isCall, isCreate, isDelete, isDrop, isExec, isInsert, isOther, isRun, isSelect, isUpdatepublic NutSql(String sql)
public Sql setEntity(Entity<?> en)
DaoStatementsetEntity 在接口中 DaoStatementsetEntity 在接口中 SqlsetEntity 在类中 NutStatementen - 实体public ValueAdaptor[] getAdaptors()
DaoStatementgetAdaptors 在接口中 DaoStatementpublic void setValueAdaptor(String name, ValueAdaptor adaptor)
Sql
默认的,Sql 的实现类会自动根据你设置的值,自动为所有的参数设置适配器。
但是,有些时候,你可能传入了 null 值或者其他的特殊对象,
这里允许你主动为其设置一个适配器,这样你就有了终极手段最合理的适配你的参数对象
setValueAdaptor 在接口中 Sqlname - 对应参数的名称adaptor - 适配器实例public Object[][] getParamMatrix()
DaoStatement矩阵的每一行相当于执行一条语句
参数表的下标意义为: Object[行][列]
getParamMatrix 在接口中 DaoStatementpublic String toPreparedStatement()
DaoStatementtoPreparedStatement 在接口中 DaoStatementpublic VarSet vars()
Sql这个集合允许你为 SQL 的变量占位符设值
public VarSet params()
Sql
集合是一个个的名值对,你设置了值的地方,会在执行时,被设置到 PreparedStatement中。
这样省却了你一个一个计算 ? 位置的烦恼
public VarIndex paramIndex()
paramIndex 在接口中 Sqlpublic void clearBatch()
SqlclearBatch 在接口中 Sqlpublic Sql setCallback(SqlCallback callback)
Sql
当然如果不是 SELECT 语句,那么你依然可以设置一个回调,
当你的语句执行完毕后, 会调用它(Connection 不会被 commit),但是 ResultSet 参数会是 null
setCallback 在接口中 Sqlcallback - 回调函数public Sql setCondition(Condition cnd)
SqlsetCondition 在接口中 Sqlcnd - 条件public void onBefore(Connection conn)
DaoStatement这个接口函数你基本不会直接使用的
onBefore 在接口中 DaoStatementconn - 当前执行语句的连接public void onAfter(Connection conn, ResultSet rs) throws SQLException
DaoStatement这个接口函数你基本不会直接使用的
onAfter 在接口中 DaoStatementconn - 当前执行语句的连接rs - 当前语句执行的结果集SQLException - 回调函数抛出的异常public String toString()
DaoStatementtoString 在接口中 DaoStatementtoString 在类中 NutStatementpublic NutSql setPager(Pager pager)
SqlsetPager 在接口中 DaoStatementsetPager 在接口中 Sqlpublic void setSourceSql(String sql)
setSourceSql 在接口中 Sqlpublic String getSourceSql()
getSourceSql 在接口中 SqlCopyright © 2014. All rights reserved.