Search in sources :

Example 1 with FetchBean

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

the class TnBasicSelectHandler method isUseFunctionalResultSet.

protected boolean isUseFunctionalResultSet() {
    // for safety result
    final FetchBean fcbean = FetchAssistContext.getFetchBeanOnThread();
    if (fcbean != null && fcbean.getSafetyMaxResultSize() > 0) {
        // priority one
        return true;
    }
    final FetchNarrowingBean fnbean = FetchAssistContext.getFetchNarrowingBeanOnThread();
    if (fnbean != null && fnbean.isFetchNarrowingEffective()) {
        // for unsupported paging (ConditionBean)
        if (fnbean.isFetchNarrowingSkipStartIndexEffective() || fnbean.isFetchNarrowingLoopCountEffective()) {
            // priority two
            return true;
        }
        // for auto paging (OutsideSql)
        if (OutsideSqlContext.isExistOutsideSqlContextOnThread()) {
            final OutsideSqlContext outsideSqlContext = OutsideSqlContext.getOutsideSqlContextOnThread();
            if (outsideSqlContext.isOffsetByCursorForcedly() || outsideSqlContext.isLimitByCursorForcedly()) {
                // priority three
                return true;
            }
        }
    }
    return false;
}
Also used : FetchBean(org.dbflute.jdbc.FetchBean) OutsideSqlContext(org.dbflute.outsidesql.OutsideSqlContext) FetchNarrowingBean(org.dbflute.cbean.paging.FetchNarrowingBean)

Example 2 with FetchBean

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

the class TnBasicSelectHandler method doQueryResult.

protected ResultSet doQueryResult(PreparedStatement ps) throws SQLException {
    // /- - - - - - - - - - - - - - - - - - - - - - - - - - -
    // All select statements on DBFlute use this result set.
    // - - - - - - - - - -/
    final ResultSet rs = executeQuery(ps);
    if (!isUseFunctionalResultSet()) {
        return rs;
    }
    if (isInternalDebugEnabled()) {
        _log.debug("...Wrapping result set by functional one");
    }
    final FetchBean selbean = FetchAssistContext.getFetchBeanOnThread();
    final TnFetchAssistResultSet wrapper;
    if (OutsideSqlContext.isExistOutsideSqlContextOnThread()) {
        final OutsideSqlContext context = OutsideSqlContext.getOutsideSqlContextOnThread();
        final boolean offsetByCursorForcedly = context.isOffsetByCursorForcedly();
        final boolean limitByCursorForcedly = context.isLimitByCursorForcedly();
        wrapper = createFunctionalResultSet(rs, selbean, offsetByCursorForcedly, limitByCursorForcedly);
    } else {
        wrapper = createFunctionalResultSet(rs, selbean, false, false);
    }
    return wrapper;
}
Also used : FetchBean(org.dbflute.jdbc.FetchBean) OutsideSqlContext(org.dbflute.outsidesql.OutsideSqlContext) ResultSet(java.sql.ResultSet) TnFetchAssistResultSet(org.dbflute.s2dao.jdbc.TnFetchAssistResultSet) TnFetchAssistResultSet(org.dbflute.s2dao.jdbc.TnFetchAssistResultSet)

Example 3 with FetchBean

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

the class TnProcedureHandler method wrapResultSetIfNeeds.

protected ResultSet wrapResultSetIfNeeds(Object pmb, ResultSet rs) {
    if (pmb instanceof FetchBean) {
        final FetchBean fcbean = (FetchBean) pmb;
        final int safetyMaxResultSize = fcbean.getSafetyMaxResultSize();
        if (safetyMaxResultSize > 0) {
            // wrap for check safety
            return new TnFetchAssistResultSet(rs, fcbean, false, false);
        }
    }
    return rs;
}
Also used : FetchBean(org.dbflute.jdbc.FetchBean) TnFetchAssistResultSet(org.dbflute.s2dao.jdbc.TnFetchAssistResultSet)

Example 4 with FetchBean

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

the class ContextStack method restoreAllContextOnThreadIfExists.

public static void restoreAllContextOnThreadIfExists() {
    if (!isExistContextStackOnThread()) {
        return;
    }
    final Stack<ContextStack> stackOnThread = getContextStackOnThread();
    if (stackOnThread.isEmpty()) {
        clearContextStackOnThread();
        return;
    }
    final ContextStack contextStack = stackOnThread.pop();
    final ConditionBean cb = contextStack.getConditionBean();
    if (cb != null) {
        ConditionBeanContext.setConditionBeanOnThread(cb);
    }
    final EntityRowHandler<? extends Entity> entityRowHandler = contextStack.getEntityRowHandler();
    if (entityRowHandler != null) {
        ConditionBeanContext.setEntityRowHandlerOnThread(entityRowHandler);
    }
    final OutsideSqlContext outsideSqlContext = contextStack.getOutsideSqlContext();
    if (outsideSqlContext != null) {
        OutsideSqlContext.setOutsideSqlContextOnThread(outsideSqlContext);
    }
    final FetchBean fetchBean = contextStack.getFetchBean();
    if (fetchBean != null) {
        FetchAssistContext.setFetchBeanOnThread(fetchBean);
    }
    final Map<String, Object> internalMap = contextStack.getInternalMap();
    if (internalMap != null) {
        InternalMapContext.clearInternalMapContextOnThread();
        final Set<Entry<String, Object>> entrySet = internalMap.entrySet();
        for (Entry<String, Object> entry : entrySet) {
            InternalMapContext.setObject(entry.getKey(), entry.getValue());
        }
    }
    final ResourceContext resourceContext = contextStack.getResourceContext();
    if (resourceContext != null) {
        ResourceContext.setResourceContextOnThread(resourceContext);
    }
}
Also used : FetchBean(org.dbflute.jdbc.FetchBean) ConditionBean(org.dbflute.cbean.ConditionBean) Entry(java.util.Map.Entry) OutsideSqlContext(org.dbflute.outsidesql.OutsideSqlContext)

Aggregations

FetchBean (org.dbflute.jdbc.FetchBean)4 OutsideSqlContext (org.dbflute.outsidesql.OutsideSqlContext)3 TnFetchAssistResultSet (org.dbflute.s2dao.jdbc.TnFetchAssistResultSet)2 ResultSet (java.sql.ResultSet)1 Entry (java.util.Map.Entry)1 ConditionBean (org.dbflute.cbean.ConditionBean)1 FetchNarrowingBean (org.dbflute.cbean.paging.FetchNarrowingBean)1