Search in sources :

Example 1 with AbstractSqlAction

use of info.xiancloud.dao.core.action.AbstractSqlAction in project xian by happyyangyuan.

the class DaoUnit method logSql.

/**
 * 打印sql语句,它不会将sql执行,只是打印sql语句。
 * 仅供内部测试使用
 *
 * @param daoUnitClass unit class
 * @param map          parameter map
 */
public static void logSql(Class daoUnitClass, Map<String, Object> map) {
    XianConnection connection = PoolFactory.getPool().getMasterDatasource().getConnection().blockingGet();
    DaoUnit daoUnit;
    try {
        daoUnit = (DaoUnit) daoUnitClass.newInstance();
        for (SqlAction action : daoUnit.getActions()) {
            ((AbstractSqlAction) action).setConnection(connection);
            ((AbstractSqlAction) action).setMap(map);
            action.logSql(map);
        }
    } catch (InstantiationException | IllegalAccessException e) {
        e.printStackTrace();
    }
    PoolFactory.getPool().destroyPoolIfNot();
}
Also used : AbstractSqlAction(info.xiancloud.dao.core.action.AbstractSqlAction) XianConnection(info.xiancloud.dao.core.connection.XianConnection) AbstractSqlAction(info.xiancloud.dao.core.action.AbstractSqlAction) SqlAction(info.xiancloud.dao.core.action.SqlAction)

Aggregations

AbstractSqlAction (info.xiancloud.dao.core.action.AbstractSqlAction)1 SqlAction (info.xiancloud.dao.core.action.SqlAction)1 XianConnection (info.xiancloud.dao.core.connection.XianConnection)1