use of org.dbflute.cbean.sqlclause.orderby.OrderByElement in project dbflute-core by dbflute.
the class AbstractSqlClause method doRegisterOrderBy.
protected void doRegisterOrderBy(String orderByProperty, boolean ascOrDesc, ColumnInfo columnInfo, boolean derived) {
try {
_orderByEffective = true;
final List<String> orderByList = new ArrayList<String>();
{
final StringTokenizer st = new StringTokenizer(orderByProperty, "/");
while (st.hasMoreElements()) {
orderByList.add(st.nextToken());
}
}
for (String orderBy : orderByList) {
_orderByEffective = true;
final String aliasName;
final String columnName;
if (orderBy.indexOf(".") < 0) {
aliasName = null;
columnName = orderBy;
} else {
aliasName = orderBy.substring(0, orderBy.lastIndexOf("."));
columnName = orderBy.substring(orderBy.lastIndexOf(".") + 1);
}
final OrderByElement element = newOrderByElement(columnInfo, derived, aliasName, columnName);
if (ascOrDesc) {
element.setupAsc();
} else {
element.setupDesc();
}
element.setGearedCipherManager(_gearedCipherManager);
getOrderBy().addOrderByElement(element);
}
} catch (RuntimeException e) {
String msg = "Failed to register order-by:";
msg = msg + " orderByProperty=" + orderByProperty + " ascOrDesc=" + ascOrDesc;
msg = msg + " table=" + _tableDbName;
throw new IllegalStateException(msg, e);
}
}
use of org.dbflute.cbean.sqlclause.orderby.OrderByElement in project dbflute-core by dbflute.
the class AbstractBehaviorReadable method helpSelectCursorCheckingOrderByPK.
protected void helpSelectCursorCheckingOrderByPK(CB cb, CursorSelectOption option) {
if (option.isOrderByPK()) {
final OrderByClause orderByClause = cb.getOrderByComponent();
final OrderByElement orderByFirstElement = orderByClause.getOrderByFirstElement();
if (orderByFirstElement == null || !orderByFirstElement.getColumnInfo().isPrimary()) {
String msg = "The cursor select by paging needs order by primary key: " + cb.asTableDbName();
throw new IllegalConditionBeanOperationException(msg);
}
}
}
use of org.dbflute.cbean.sqlclause.orderby.OrderByElement in project dbflute-core by dbflute.
the class AbstractConditionQuery method xdoWithManualOrder.
protected void xdoWithManualOrder(ManualOrderOption mob) {
assertObjectNotNull("withManualOrder(mob)", mob);
final OrderByElement lastElement = xgetSqlClause().getOrderByLastElement();
xcheckManualOrderState(mob, lastElement);
xcheckManualOrderUnique(mob, lastElement);
mob.bind((themeKey, orderValue) -> {
return xregisterManualOrderParameterToThemeList(themeKey, orderValue);
});
if (mob.hasOrderByCalculation()) {
final ConditionBean dreamCruiseCB = xgetBaseCB().xcreateDreamCruiseCB();
dreamCruiseCB.overTheWaves(xcreateManualOrderSpecifiedColumn(dreamCruiseCB));
mob.xinitOrderByCalculation(xgetBaseCB(), dreamCruiseCB);
}
mob.validate();
xgetSqlClause().addManualOrderToPreviousOrderByElement(mob);
}
use of org.dbflute.cbean.sqlclause.orderby.OrderByElement in project dbflute-core by dbflute.
the class AbstractConditionQuery method xcreateManualOrderSpecifiedColumn.
protected SpecifiedColumn xcreateManualOrderSpecifiedColumn(ConditionBean dreamCruiseCB) {
final OrderByElement orderByLastElement = xgetSqlClause().getOrderByLastElement();
final String aliasName = orderByLastElement.getAliasName();
final String columnName = orderByLastElement.getColumnName();
final ColumnInfo columnInfo = orderByLastElement.getColumnInfo();
final boolean derived = orderByLastElement.isDerivedOrderBy();
return new SpecifiedColumn(aliasName, columnInfo, dreamCruiseCB, columnName, derived);
}
Aggregations