浏览 3347 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2007-05-14
那么ibatis有没有这样的机制呢? 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2007-05-14
有:ExecuteListener
|
|
返回顶楼 | |
发表时间:2007-05-14
引用 Readonly 5 小时前 有:ExecuteListener 请问有例子吗?怎样加入啊 |
|
返回顶楼 | |
发表时间:2007-05-14
package com.longtop.core.ibatis; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import com.ibatis.sqlmap.engine.mapping.parameter.ParameterMapping; import com.ibatis.sqlmap.engine.mapping.statement.ExecuteListener; import com.ibatis.sqlmap.engine.mapping.statement.MappedStatement; public class AuditListener implements ExecuteListener { private static final Log logger = LogFactory.getLog(AuditListener.class); public void onExecuteStatement(MappedStatement mappedStatement) { ParameterMapping[] mappings=mappedStatement.getParameterMap().getParameterMappings(); logger.debug(mappedStatement.getId()); logger.debug(mappedStatement.getSql().getSql(null, null)); for (int i = 0; i < mappings.length; i++) { logger.debug(mappings[i].getPropertyName()+"-----"+mappedStatement.getParameterMap().getParameterObjectValues(null, null)[i]); } } } 这个接口怎么得不到执行时的状态、参数值啊 |
|
返回顶楼 | |
发表时间:2007-05-14
另外用SqlExecutor的子类可以实现,难道要我自己写一个接口吗?到底行不行啊
@Override public void executeQuery(RequestScope request, Connection conn, String sql, Object[] parameters, int skipResults, int maxResults, RowHandlerCallback callback) throws SQLException { if (executeListeners != null) { for (Iterator iter = executeListeners.iterator(); iter.hasNext();) { ExecuteListener element = (ExecuteListener) iter.next(); request.getStatement().addExecuteListener(element); } } super.executeQuery(request, conn, sql, parameters, skipResults, maxResults, callback); } |
|
返回顶楼 | |