use of org.nutz.dao.sql.DaoStatement in project nutz by nutzam.
the class DaoLogInterceptor method filter.
public void filter(DaoInterceptorChain chain) throws DaoException {
DaoStatement statement = chain.getDaoStatement();
if (statement != null) {
NutDaoExecutor.printSQL(statement);
}
chain.doChain();
}
use of org.nutz.dao.sql.DaoStatement in project nutz by nutzam.
the class NutDao method func2.
public Object func2(Class<?> classOfT, String func2Name, String colName, Condition cnd) {
Entity<?> en = holder.getEntity(classOfT);
if (null != en.getField(colName))
colName = en.getField(colName).getColumnNameInSql();
DaoStatement pojo = pojoMaker.makeFunc(en.getViewName(), func2Name, colName).append(Pojos.Items.cnd(cnd)).setAfter(_pojo_fetchObject).setEntity(en);
_exec(pojo);
return pojo.getResult();
}
use of org.nutz.dao.sql.DaoStatement in project nutz by nutzam.
the class NutDao method func.
public int func(String tableName, String funcName, String colName, Condition cnd) {
DaoStatement pojo = pojoMaker.makeFunc(tableName, funcName, colName).append(Pojos.Items.cnd(cnd)).setAfter(_pojo_fetchInt);
_exec(pojo);
return pojo.getInt();
}
use of org.nutz.dao.sql.DaoStatement in project nutz by nutzam.
the class NutDaoExecutor method _runStatement.
private void _runStatement(Connection conn, DaoStatement st) throws SQLException {
boolean statIsClosed = false;
Statement stat = null;
String sql = st.toPreparedStatement();
try {
stat = conn.createStatement();
stat.execute(sql);
st.getContext().setUpdateCount(stat.getUpdateCount());
st.onAfter(conn, null, stat);
stat.close();
statIsClosed = true;
} finally {
if (!statIsClosed)
Daos.safeClose(stat);
}
// 打印更详细的调试信息
if (log.isTraceEnabled())
log.trace("...DONE");
}
use of org.nutz.dao.sql.DaoStatement in project nutz by nutzam.
the class DaoInterceptorChain method invoke.
/**
* 这是DaoExecutor会执行的方法,拦截器内不要执行这个方法!! 这里也是拦截器开始生效的地方.
*/
public void invoke(Connection conn) throws Exception {
for (DaoStatement st : sts) {
if (st == null) {
if (log.isInfoEnabled())
log.info("Found a null DaoStatement(SQL), ingore it ~~");
continue;
}
current = 0;
daoStatement = st;
this.connection = conn;
doChain();
}
}
Aggregations