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;
}
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;
}
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;
}
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);
}
}
Aggregations