use of org.dbflute.cbean.ConditionBean in project dbflute-core by dbflute.
the class AbstractSelectCBReturnEntityCommand method beforeGettingSqlExecution.
// ===================================================================================
// Process Callback
// ================
public void beforeGettingSqlExecution() {
assertStatus("beforeGettingSqlExecution");
final ConditionBean cb = _conditionBean;
FetchAssistContext.setFetchBeanOnThread(cb);
ConditionBeanContext.setConditionBeanOnThread(cb);
}
use of org.dbflute.cbean.ConditionBean in project dbflute-core by dbflute.
the class TnQueryDeleteDynamicCommand method execute.
// ===================================================================================
// Execute
// =======
public Object execute(Object[] args) {
// analyze arguments
final ConditionBean cb = extractConditionBeanWithCheck(args);
final DeleteOption<ConditionBean> option = extractUpdateOptionWithCheck(args);
prepareStatementConfigOnThreadIfExists(option);
// arguments for execution (not contains an option)
final String[] argNames = new String[] { "pmb" };
final Class<?>[] argTypes = new Class<?>[] { cb.getClass() };
final Object[] realArgs = new Object[] { cb };
// prepare context
final CommandContext context;
{
final String twoWaySql = buildQueryDeleteTwoWaySql(cb, option);
context = createCommandContext(twoWaySql, argNames, argTypes, realArgs);
}
// execute
final TnCommandContextHandler handler = createCommandContextHandler(context);
handler.setExceptionMessageSqlArgs(context.getBindVariables());
final int rows = handler.execute(realArgs);
return Integer.valueOf(rows);
}
use of org.dbflute.cbean.ConditionBean in project dbflute-core by dbflute.
the class TnQueryUpdateDynamicCommand method execute.
// ===================================================================================
// Execute
// =======
public Object execute(Object[] args) {
// analyze arguments
final Entity entity = extractEntityWithCheck(args);
final ConditionBean cb = extractConditionBeanWithCheck(args);
final UpdateOption<ConditionBean> option = extractUpdateOptionWithCheck(args);
prepareStatementConfigOnThreadIfExists(option);
// arguments for execution (not contains an option)
final String[] argNames = new String[] { "entity", "pmb" };
final Class<?>[] argTypes = new Class<?>[] { entity.getClass(), cb.getClass() };
final Object[] realArgs = new Object[] { entity, cb };
// prepare context
final List<TnPropertyType> boundPropTypeList = new ArrayList<TnPropertyType>();
final CommandContext context;
{
final String twoWaySql = buildQueryUpdateTwoWaySql(entity, cb, option, boundPropTypeList);
if (twoWaySql == null) {
// non execute
return 0;
}
context = createCommandContext(twoWaySql, argNames, argTypes, realArgs);
}
// execute
final TnCommandContextHandler handler = createCommandContextHandler(context);
handler.setExceptionMessageSqlArgs(context.getBindVariables());
handler.setFirstBoundPropTypeList(boundPropTypeList);
final int rows = handler.execute(realArgs);
return Integer.valueOf(rows);
}
use of org.dbflute.cbean.ConditionBean in project dbflute-core by dbflute.
the class PagingInvoker method throwPagingStatusInvalidException.
protected void throwPagingStatusInvalidException(PagingBean pagingBean) {
final boolean cbean = pagingBean instanceof ConditionBean;
final String name = cbean ? "condition-bean" : "parameter-bean";
final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
br.addNotice("The status of paging was INVALID. (paging parameters was not found)");
br.addItem("Advice");
br.addElement("Confirm your logic for paging of " + name + ".");
br.addElement("Paging execution needs paging parameters 'pageSize' and 'pageNumber'.");
br.addElement("For example:");
br.addElement(" (x):");
if (cbean) {
br.addElement(" MemberCB cb = new MemberCB();");
br.addElement(" cb.query().set...;");
br.addElement(" ... = memberBhv.selectPage(cb);");
} else {
br.addElement(" SimpleMemberPmb pmb = new SimpleMemberPmb();");
br.addElement(" pmb.set...;");
br.addElement(" ... = memberBhv.outsideSql().manualPaging().selectPage(...);");
}
br.addElement(" (o):");
if (cbean) {
br.addElement(" MemberCB cb = new MemberCB();");
br.addElement(" cb.query().set...;");
br.addElement(" cb.paging(20, 2); // *Point!");
br.addElement(" ... = memberBhv.selectPage(cb);");
} else {
br.addElement(" SimpleMemberPmb pmb = new SimpleMemberPmb();");
br.addElement(" pmb.set...;");
br.addElement(" pmb.paging(20, 2); // *Point!");
br.addElement(" ... = memberBhv.outsideSql().manualPaging().selectPage(...);");
}
br.addItem("PagingBean");
br.addElement(pagingBean);
final String msg = br.buildExceptionMessage();
throw new PagingStatusInvalidException(msg);
}
use of org.dbflute.cbean.ConditionBean in project dbflute-core by dbflute.
the class FunctionFilterOption method buildDreamCruiseTicketStatement.
protected String buildDreamCruiseTicketStatement(Object value) {
final String bindPath;
final SpecifiedColumn specifiedColumn = ((SpecifiedColumn) value);
final String columnExp;
if (_removeCalcAlias) {
// e.g. VaryingUpdate
columnExp = specifiedColumn.toColumnSqlName().toString();
} else {
// normally here
columnExp = specifiedColumn.toColumnRealName().toString();
}
if (specifiedColumn.hasSpecifyCalculation()) {
specifiedColumn.xinitSpecifyCalculation();
final HpCalcSpecification<ConditionBean> calcSpecification = specifiedColumn.getSpecifyCalculation();
if (_removeCalcAlias) {
// e.g. VaryingUpdate
bindPath = calcSpecification.buildStatementToSpecifidNameRemovedCalcAlias(columnExp);
} else {
// normally here
bindPath = calcSpecification.buildStatementToSpecifidName(columnExp);
}
} else {
bindPath = columnExp;
}
return bindPath;
}
Aggregations