Search in sources :

Example 51 with ColumnInfo

use of org.dbflute.dbmeta.info.ColumnInfo in project dbflute-core by dbflute.

the class DerivedReferrer method setupUnionMainForFixedCondition.

protected void setupUnionMainForFixedCondition(StringBuilder keySb, String tableAliasName, ColumnSqlName derivedColumnSqlName) {
    // all columns because fixed condition might contain them
    final List<ColumnInfo> columnInfoList = _subQueryDBMeta.getColumnInfoList();
    for (ColumnInfo columnInfo : columnInfoList) {
        final ColumnSqlName sqlName = columnInfo.getColumnSqlName();
        if (sqlName.equals(derivedColumnSqlName)) {
            // to suppress same columns selected
            continue;
        }
        final ColumnRealName realName = ColumnRealName.create(tableAliasName, columnInfo.getColumnSqlName());
        keySb.append(keySb.length() > 0 ? ", " : "");
        keySb.append(realName);
    }
}
Also used : ColumnSqlName(org.dbflute.dbmeta.name.ColumnSqlName) ColumnInfo(org.dbflute.dbmeta.info.ColumnInfo) ColumnRealName(org.dbflute.dbmeta.name.ColumnRealName)

Example 52 with ColumnInfo

use of org.dbflute.dbmeta.info.ColumnInfo in project dbflute-core by dbflute.

the class DerivedReferrer method buildUnionMainPartClause.

protected String buildUnionMainPartClause(ColumnSqlName relatedColumnSqlName, String tableAliasName, ColumnRealName derivedColumnRealName, ColumnSqlName derivedColumnSqlName, String correlatedFixedCondition) {
    // derivedColumnSqlName : e.g. PURCHASE_PRICE
    // derivedRealSqlName   : might be sub-query
    final ColumnSqlName derivedRealSqlName = derivedColumnRealName.getColumnSqlName();
    final StringBuilder keySb = new StringBuilder();
    if (isFixedCondition(correlatedFixedCondition)) {
        setupUnionMainForFixedCondition(keySb, tableAliasName, derivedColumnSqlName);
    } else {
        // no fixed condition, mainly here
        final List<ColumnInfo> pkList = _subQueryDBMeta.getPrimaryInfo().getPrimaryColumnList();
        for (ColumnInfo pk : pkList) {
            final ColumnSqlName pkSqlName = pk.getColumnSqlName();
            if (pkSqlName.equals(derivedRealSqlName) || pkSqlName.equals(relatedColumnSqlName)) {
                // to suppress same columns selected
                continue;
            }
            keySb.append(keySb.length() > 0 ? ", " : "");
            keySb.append(ColumnRealName.create(tableAliasName, pk.getColumnSqlName()));
        }
        if (!relatedColumnSqlName.equals(derivedRealSqlName)) {
            // to suppress same columns selected
            keySb.append(keySb.length() > 0 ? ", " : "");
            keySb.append(ColumnRealName.create(tableAliasName, relatedColumnSqlName));
        }
    }
    setupUnionMainForDerivedColumn(keySb, derivedColumnRealName, derivedColumnSqlName, derivedRealSqlName);
    return completeUnionMainWholeClause(tableAliasName, keySb);
}
Also used : ColumnSqlName(org.dbflute.dbmeta.name.ColumnSqlName) ColumnInfo(org.dbflute.dbmeta.info.ColumnInfo)

Example 53 with ColumnInfo

use of org.dbflute.dbmeta.info.ColumnInfo in project dbflute-core by dbflute.

the class DerivedReferrer method buildUnionMainPartClause.

protected String buildUnionMainPartClause(ColumnRealName[] correlatedColumnRealNames, ColumnSqlName[] relatedColumnSqlNames, String tableAliasName, ColumnRealName derivedColumnRealName, ColumnSqlName derivedColumnSqlName, String correlatedFixedCondition) {
    // similar to simple primary key so refer it
    final StringBuilder keySb = new StringBuilder();
    final ColumnSqlName derivedRealSqlName = derivedColumnRealName.getColumnSqlName();
    if (isFixedCondition(correlatedFixedCondition)) {
        setupUnionMainForFixedCondition(keySb, tableAliasName, derivedColumnSqlName);
    } else {
        // no fixed condition, mainly here
        final Set<ColumnSqlName> relatedColumnSqlSet = new HashSet<ColumnSqlName>();
        for (ColumnSqlName columnSqlName : relatedColumnSqlNames) {
            relatedColumnSqlSet.add(columnSqlName);
        }
        final ColumnSqlName derivedSqlName = derivedRealSqlName;
        final List<ColumnInfo> pkList = _subQueryDBMeta.getPrimaryInfo().getPrimaryColumnList();
        for (ColumnInfo pk : pkList) {
            final ColumnSqlName pkSqlName = pk.getColumnSqlName();
            if (pkSqlName.equals(derivedSqlName) || relatedColumnSqlSet.contains(pkSqlName)) {
                // to suppress same columns selected
                continue;
            }
            keySb.append(keySb.length() > 0 ? ", " : "");
            keySb.append(ColumnRealName.create(tableAliasName, pk.getColumnSqlName()));
        }
        for (ColumnSqlName relatedSqlName : relatedColumnSqlNames) {
            if (relatedSqlName.equals(derivedSqlName)) {
                // to suppress same columns selected
                continue;
            }
            keySb.append(keySb.length() > 0 ? ", " : "");
            keySb.append(ColumnRealName.create(tableAliasName, relatedSqlName));
        }
    }
    setupUnionMainForDerivedColumn(keySb, derivedColumnRealName, derivedColumnSqlName, derivedRealSqlName);
    return completeUnionMainWholeClause(tableAliasName, keySb);
}
Also used : ColumnSqlName(org.dbflute.dbmeta.name.ColumnSqlName) ColumnInfo(org.dbflute.dbmeta.info.ColumnInfo) HashSet(java.util.HashSet)

Example 54 with ColumnInfo

use of org.dbflute.dbmeta.info.ColumnInfo in project dbflute-core by dbflute.

the class AbstractDBMeta method cci.

protected // column name
ColumnInfo cci(// column name
String columnDbName, // column name
String columnSqlName, // column name
String columnSynonym, // column name
String columnAlias, // property info
Class<?> objectNativeType, // property info
String propertyName, // property info
Class<?> propertyAccessType, // column basic check
boolean primary, // column basic check
boolean autoIncrement, // column basic check
boolean notNull, // column type
String columnDbType, // column type
Integer columnSize, // column type
Integer decimalDigits, // column type
Integer datetimePrecision, // column type
String defaultValue, // column others
boolean commonColumn, // column others
OptimisticLockType optimisticLockType, // column others
String columnComment, // relation property
String foreignListExp, // relation property
String referrerListExp, // various info
ClassificationMeta classificationMeta, // various info
boolean canBeNullObject) {
    // createColumnInfo()
    final Class<?> realPt = chooseColumnPropertyAccessType(objectNativeType, propertyName, propertyAccessType);
    final String delimiter = ",";
    List<String> foreignPropList = null;
    if (foreignListExp != null && foreignListExp.trim().length() > 0) {
        foreignPropList = splitListTrimmed(foreignListExp, delimiter);
    }
    List<String> referrerPropList = null;
    if (referrerListExp != null && referrerListExp.trim().length() > 0) {
        referrerPropList = splitListTrimmed(referrerListExp, delimiter);
    }
    final PropertyMethodFinder propertyMethodFinder = createColumnPropertyMethodFinder();
    return new ColumnInfo(this, columnDbName, columnSqlName, columnSynonym, columnAlias, objectNativeType, propertyName, realPt, primary, autoIncrement, notNull, columnDbType, columnSize, decimalDigits, datetimePrecision, defaultValue, commonColumn, optimisticLockType, columnComment, foreignPropList, referrerPropList, classificationMeta, canBeNullObject, propertyMethodFinder);
}
Also used : ColumnInfo(org.dbflute.dbmeta.info.ColumnInfo) PropertyMethodFinder(org.dbflute.dbmeta.property.PropertyMethodFinder)

Example 55 with ColumnInfo

use of org.dbflute.dbmeta.info.ColumnInfo in project dbflute-core by dbflute.

the class SqlClauseOracle method lockForUpdate.

// ===================================================================================
// Lock Override
// =============
/**
 * {@inheritDoc}
 */
public void lockForUpdate() {
    final DBMeta dbmeta = findDBMeta(_tableDbName);
    final String basePointAliasName = getBasePointAliasName();
    if (dbmeta.hasPrimaryKey()) {
        final ColumnSqlName primaryKeyName = dbmeta.getPrimaryInfo().getFirstColumn().getColumnSqlName();
        _lockSqlSuffix = " for update of " + basePointAliasName + "." + primaryKeyName;
    } else {
        final ColumnSqlName randomColumnName = ((ColumnInfo) dbmeta.getColumnInfoList().get(0)).getColumnSqlName();
        _lockSqlSuffix = " for update of " + basePointAliasName + "." + randomColumnName;
    }
}
Also used : ColumnSqlName(org.dbflute.dbmeta.name.ColumnSqlName) DBMeta(org.dbflute.dbmeta.DBMeta) ColumnInfo(org.dbflute.dbmeta.info.ColumnInfo)

Aggregations

ColumnInfo (org.dbflute.dbmeta.info.ColumnInfo)73 DBMeta (org.dbflute.dbmeta.DBMeta)27 ColumnSqlName (org.dbflute.dbmeta.name.ColumnSqlName)14 Entity (org.dbflute.Entity)8 SpecifiedColumn (org.dbflute.cbean.dream.SpecifiedColumn)7 SqlClause (org.dbflute.cbean.sqlclause.SqlClause)7 ArrayList (java.util.ArrayList)6 LinkedHashMap (java.util.LinkedHashMap)5 PrimaryInfo (org.dbflute.dbmeta.info.PrimaryInfo)5 ColumnRealName (org.dbflute.dbmeta.name.ColumnRealName)5 List (java.util.List)4 ForeignInfo (org.dbflute.dbmeta.info.ForeignInfo)4 HashSet (java.util.HashSet)3 ColumnFunctionCipher (org.dbflute.cbean.cipher.ColumnFunctionCipher)3 IllegalConditionBeanOperationException (org.dbflute.exception.IllegalConditionBeanOperationException)3 Method (java.lang.reflect.Method)2 LocalDate (java.time.LocalDate)2 LocalDateTime (java.time.LocalDateTime)2 Collection (java.util.Collection)2 Date (java.util.Date)2