Search in sources :

Example 6 with SpecifiedColumn

use of org.dbflute.cbean.dream.SpecifiedColumn in project dbflute-core by dbflute.

the class HpAbstractSpecification method doColumn.

protected SpecifiedColumn doColumn(String columnName) {
    // for extended class
    checkSpecifiedThemeColumnStatus(columnName);
    if (isSpecifiedColumn(columnName)) {
        // returns the same instance as the specified before
        return getSpecifiedColumn(columnName);
    }
    assertColumn(columnName);
    callQuery();
    if (isRequiredColumnSpecificationEnabled()) {
        _alreadySpecifiedRequiredColumn = true;
        doSpecifyRequiredColumn();
    }
    final SqlClause sqlClause = _baseCB.getSqlClause();
    final String tableAliasName;
    if (_query.isBaseQuery()) {
        tableAliasName = sqlClause.getBasePointAliasName();
    } else {
        final String relationPath = _query.xgetRelationPath();
        final int nestLevel = _query.xgetNestLevel();
        tableAliasName = sqlClause.resolveJoinAliasName(relationPath, nestLevel);
        keepDreamCruiseJourneyLogBookIfNeeds(relationPath, tableAliasName);
        reflectDreamCruiseWhereUsedToJoin(relationPath, tableAliasName);
    }
    final SpecifiedColumn specifiedColumn = createSpecifiedColumn(columnName, tableAliasName);
    sqlClause.specifySelectColumn(specifiedColumn);
    saveSpecifiedColumn(columnName, specifiedColumn);
    return specifiedColumn;
}
Also used : SqlClause(org.dbflute.cbean.sqlclause.SqlClause) SpecifiedColumn(org.dbflute.cbean.dream.SpecifiedColumn)

Example 7 with SpecifiedColumn

use of org.dbflute.cbean.dream.SpecifiedColumn in project dbflute-core by dbflute.

the class ConditionBeanExceptionThrower method throwSpecifyEveryColumnAlreadySpecifiedColumnException.

public void throwSpecifyEveryColumnAlreadySpecifiedColumnException(String tableDbName, Map<String, SpecifiedColumn> specifiedColumnMap) {
    final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
    br.addNotice("The SpecifyEveryColumn is specified after SpecifyColumn.");
    br.addItem("Advice");
    br.addElement("You cannot specify columns with every column.");
    br.addElement("For example:");
    br.addElement("  (x):");
    br.addElement("    memberBhv.batchUpdate(memberList, colCB -> {");
    br.addElement("        colCB.specify().columnMemberName();");
    br.addElement("        colCB.specify().everyColumn(); // *No");
    br.addElement("    });");
    br.addElement("  (o):");
    br.addElement("    memberBhv.batchUpdate(memberList, colCB -> {");
    br.addElement("        colCB.specify().everyColumn();");
    br.addElement("    });");
    br.addItem("Base Table");
    br.addElement(tableDbName);
    if (specifiedColumnMap != null) {
        // basically true
        br.addItem("Specified Column");
        final Collection<SpecifiedColumn> columnList = specifiedColumnMap.values();
        for (SpecifiedColumn column : columnList) {
            br.addElement(column);
        }
    }
    final String msg = br.buildExceptionMessage();
    throw new SpecifyEveryColumnAlreadySpecifiedColumnException(msg);
}
Also used : ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) SpecifyEveryColumnAlreadySpecifiedColumnException(org.dbflute.exception.SpecifyEveryColumnAlreadySpecifiedColumnException) SpecifiedColumn(org.dbflute.cbean.dream.SpecifiedColumn)

Example 8 with SpecifiedColumn

use of org.dbflute.cbean.dream.SpecifiedColumn in project dbflute-core by dbflute.

the class ConditionBeanExceptionThrower method throwSpecifyExceptColumnAlreadySpecifiedColumnException.

public void throwSpecifyExceptColumnAlreadySpecifiedColumnException(String tableDbName, Map<String, SpecifiedColumn> specifiedColumnMap) {
    final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
    br.addNotice("The SpecifyExceptColumn is specified after SpecifyColumn.");
    br.addItem("Advice");
    br.addElement("You cannot specify columns with except columns.");
    br.addElement("For example:");
    br.addElement("  (x):");
    br.addElement("    ... = memberBhv.selectList(cb -> {");
    br.addElement("        cb.specify().columnMemberName(");
    br.addElement("        cb.specify().exceptRecordMetaColumn(); // *No");
    br.addElement("    });");
    br.addElement("  (o):");
    br.addElement("    ... = memberBhv.selectList(cb -> {");
    br.addElement("        cb.specify().exceptRecordMetaColumn();");
    br.addElement("    });");
    br.addElement("  (o):");
    br.addElement("    ... = memberBhv.selectList(cb -> {");
    br.addElement("        cb.specify().columnMemberName()");
    br.addElement("    });");
    br.addItem("Base Table");
    br.addElement(tableDbName);
    if (specifiedColumnMap != null) {
        // basically true
        br.addItem("Specified Column");
        final Collection<SpecifiedColumn> columnList = specifiedColumnMap.values();
        for (SpecifiedColumn column : columnList) {
            br.addElement(column);
        }
    }
    final String msg = br.buildExceptionMessage();
    throw new SpecifyExceptColumnAlreadySpecifiedColumnException(msg);
}
Also used : ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) SpecifyExceptColumnAlreadySpecifiedColumnException(org.dbflute.exception.SpecifyExceptColumnAlreadySpecifiedColumnException) SpecifiedColumn(org.dbflute.cbean.dream.SpecifiedColumn)

Example 9 with SpecifiedColumn

use of org.dbflute.cbean.dream.SpecifiedColumn in project dbflute-core by dbflute.

the class ManualOrderOption method resolveBoundValue.

// -----------------------------------------------------
// Resolve Bound
// -------------
protected Object resolveBoundValue(HpManualOrderThemeListHandler handler, Object plainValue, boolean suppressBinding) {
    if (plainValue == null) {
        return null;
    }
    if (plainValue instanceof SpecifiedColumn) {
        return resolveDreamCruiseExp(plainValue);
    }
    ClassificationCodeType codeType = null;
    if (plainValue instanceof Classification) {
        final Classification cls = (Classification) plainValue;
        plainValue = handleClassificationOrderValue(cls);
        codeType = cls.meta().codeType();
    }
    final Object boundExp;
    if (suppressBinding) {
        if (plainValue instanceof String) {
            if (canBeLiteralClassificationCodeType(codeType)) {
                boundExp = plainValue;
            } else {
                String notice = "The binding of string value is unsupported on the DBMS.";
                throwUnsupportedTypeSpecifiedException(notice, plainValue);
                // unreachable
                boundExp = null;
            }
        } else if (plainValue instanceof Number) {
            boundExp = buildLiteralNumberExpression(plainValue);
        } else if (isAnyLocalDate(plainValue) || plainValue instanceof Date) {
            // #date_parade
            boundExp = buildLiteralDateExpression(plainValue);
        } else {
            String notice = "The binding of the type is unsupported on the DBMS.";
            throwUnsupportedTypeSpecifiedException(notice, plainValue);
            // unreachable
            boundExp = null;
        }
    } else {
        boundExp = handler.register(THEME_KEY, plainValue);
    }
    return boundExp;
}
Also used : ClassificationCodeType(org.dbflute.jdbc.ClassificationCodeType) Classification(org.dbflute.jdbc.Classification) SpecifiedColumn(org.dbflute.cbean.dream.SpecifiedColumn) Date(java.util.Date) LocalDate(java.time.LocalDate)

Example 10 with SpecifiedColumn

use of org.dbflute.cbean.dream.SpecifiedColumn in project dbflute-core by dbflute.

the class ManualOrderOption method resolveDreamCruiseExp.

protected Object resolveDreamCruiseExp(Object plainValue) {
    final SpecifiedColumn specifiedColumn = (SpecifiedColumn) plainValue;
    final String columnExp = specifiedColumn.toColumnRealName().toString();
    if (specifiedColumn.hasSpecifyCalculation()) {
        specifiedColumn.xinitSpecifyCalculation();
        final HpCalcSpecification<ConditionBean> calcSpecification = specifiedColumn.getSpecifyCalculation();
        return calcSpecification.buildStatementToSpecifidName(columnExp);
    }
    return columnExp;
}
Also used : SpecifiedColumn(org.dbflute.cbean.dream.SpecifiedColumn) ConditionBean(org.dbflute.cbean.ConditionBean)

Aggregations

SpecifiedColumn (org.dbflute.cbean.dream.SpecifiedColumn)20 ColumnInfo (org.dbflute.dbmeta.info.ColumnInfo)7 ColumnSqlName (org.dbflute.dbmeta.name.ColumnSqlName)4 ConditionBean (org.dbflute.cbean.ConditionBean)3 SqlClause (org.dbflute.cbean.sqlclause.SqlClause)3 IllegalConditionBeanOperationException (org.dbflute.exception.IllegalConditionBeanOperationException)3 DBMeta (org.dbflute.dbmeta.DBMeta)2 ColumnRealName (org.dbflute.dbmeta.name.ColumnRealName)2 ExceptionMessageBuilder (org.dbflute.helper.message.ExceptionMessageBuilder)2 Method (java.lang.reflect.Method)1 LocalDate (java.time.LocalDate)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 CalculationType (org.dbflute.cbean.chelper.HpCalcElement.CalculationType)1 ColumnConversionOption (org.dbflute.cbean.coption.ColumnConversionOption)1 LikeSearchOption (org.dbflute.cbean.coption.LikeSearchOption)1 OrderByElement (org.dbflute.cbean.sqlclause.orderby.OrderByElement)1