Search in sources :

Example 1 with ExecutionTimeInfo

use of org.dbflute.jdbc.ExecutionTimeInfo in project dbflute-core by dbflute.

the class TnAbstractBasicSqlHandler method hookSqlFireFinally.

protected void hookSqlFireFinally(Object nativeResult, SQLException nativeCause) {
    if (!hasSqlFireHook()) {
        return;
    }
    final SqlLogInfo sqlLogInfo = InternalMapContext.getHookSqlLogInfo();
    final Long sqlBefore = InternalMapContext.getSqlBeforeTimeMillis();
    final Long sqlAfter = InternalMapContext.getSqlAfterTimeMillis();
    final ExecutionTimeInfo timeInfo = new ExecutionTimeInfo(null, null, sqlBefore, sqlAfter);
    final SqlFireResultInfo fireResultInfo = new SqlFireResultInfo(nativeResult, sqlLogInfo, timeInfo, nativeCause);
    getSqlFireHook().hookFinally(ResourceContext.behaviorCommand(), fireResultInfo);
}
Also used : SqlLogInfo(org.dbflute.hook.SqlLogInfo) ExecutionTimeInfo(org.dbflute.jdbc.ExecutionTimeInfo) SqlFireResultInfo(org.dbflute.hook.SqlFireResultInfo)

Example 2 with ExecutionTimeInfo

use of org.dbflute.jdbc.ExecutionTimeInfo in project dbflute-core by dbflute.

the class BehaviorCommandInvoker method callbackSqlResultHanler.

protected <RESULT> void callbackSqlResultHanler(BehaviorCommand<RESULT> behaviorCommand, SqlResultHandler sqlResultHander, Object ret, Long commandBefore, Long commandAfter, RuntimeException cause) {
    final SqlLogInfo sqlLogInfo = getResultSqlLogInfo(behaviorCommand);
    final Long sqlBefore = InternalMapContext.getSqlBeforeTimeMillis();
    final Long sqlAfter = InternalMapContext.getSqlAfterTimeMillis();
    final ExecutionTimeInfo timeInfo = new ExecutionTimeInfo(commandBefore, commandAfter, sqlBefore, sqlAfter);
    final SqlResultInfo info = new SqlResultInfo(behaviorCommand, ret, sqlLogInfo, timeInfo, cause);
    sqlResultHander.handle(info);
}
Also used : SqlLogInfo(org.dbflute.hook.SqlLogInfo) ExecutionTimeInfo(org.dbflute.jdbc.ExecutionTimeInfo) SqlResultInfo(org.dbflute.hook.SqlResultInfo)

Example 3 with ExecutionTimeInfo

use of org.dbflute.jdbc.ExecutionTimeInfo in project lastaflute by lastaflute.

the class RomanticTraceableSqlResultHandler method handle.

@Override
public void handle(SqlResultInfo info) {
    final RomanticTransaction tx = TransactionRomanticContext.getRomanticTransaction();
    if (tx != null) {
        // not saved because of internal object
        final BehaviorCommandMeta meta = info.getMeta();
        final String tableName = meta.getDBMeta().getTableDispName();
        final String command = meta.getCommandName();
        final ExecutionTimeInfo timeInfo = info.getExecutionTimeInfo();
        final Long beginMillis = timeInfo.getCommandBeforeTimeMillis();
        final Long endMillis = timeInfo.getCommandAfterTimeMillis();
        final Class<?> resultType = meta.getCommandReturnType();
        final Object resultValue = info.getResult();
        tx.registerRecentResult(tableName, command, beginMillis, endMillis, resultType, resultValue, meta);
    }
}
Also used : RomanticTransaction(org.lastaflute.db.jta.RomanticTransaction) ExecutionTimeInfo(org.dbflute.jdbc.ExecutionTimeInfo) BehaviorCommandMeta(org.dbflute.bhv.core.BehaviorCommandMeta)

Aggregations

ExecutionTimeInfo (org.dbflute.jdbc.ExecutionTimeInfo)3 SqlLogInfo (org.dbflute.hook.SqlLogInfo)2 BehaviorCommandMeta (org.dbflute.bhv.core.BehaviorCommandMeta)1 SqlFireResultInfo (org.dbflute.hook.SqlFireResultInfo)1 SqlResultInfo (org.dbflute.hook.SqlResultInfo)1 RomanticTransaction (org.lastaflute.db.jta.RomanticTransaction)1