将ibatis.net中定义的statement转换为实际的sql语句
有时我们需要查看ibatisnet中statement生成的实际sql语句,
可以通过下面的方式取得:
public static string getsql(string statementname, object paramobject)
{
isqlmapper mapper = mapper.instance();
imappedstatement statement = mapper.getmappedstatement(statementname);
if (!mapper.issessionstarted)
{
mapper.openconnection();
}
requestscope scope = statement.statement.sql.getrequestscope(statement, paramobject, mapper.localsession);
return scope.preparedstatement.preparedsql;
}
原文地址: http://blog.csdn.net/billy_zh/archive/2008/09/04/2880787.aspx