Search in sources :

Example 56 with ColumnInfo

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

the class AbstractConditionQuery method registerOrderBy.

// ===================================================================================
// Order By
// ========
// -----------------------------------------------------
// Basic
// -----
protected void registerOrderBy(String columnDbName, boolean ascOrDesc) {
    final DBMeta dbmeta = xgetLocalDBMeta();
    final ColumnInfo columnInfo = dbmeta.findColumnInfo(columnDbName);
    final ColumnRealName columnRealName = toColumnRealName(columnInfo);
    xgetSqlClause().registerOrderBy(columnRealName.toString(), ascOrDesc, columnInfo);
}
Also used : DBMeta(org.dbflute.dbmeta.DBMeta) ColumnInfo(org.dbflute.dbmeta.info.ColumnInfo) ColumnRealName(org.dbflute.dbmeta.name.ColumnRealName)

Example 57 with ColumnInfo

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

the class AbstractConditionQuery method xdoMatchByLikeSearch.

// -----------------------------------------------------
// PostgreSQL/Oracle
// -----------------
protected void xdoMatchByLikeSearch(List<ColumnInfo> textColumnList, String conditionValue) {
    if (conditionValue == null || conditionValue.length() == 0) {
        return;
    }
    assertObjectNotNull("textColumnList", textColumnList);
    if (textColumnList.isEmpty()) {
        String msg = "The argument 'textColumnList' should not be empty list.";
        throw new IllegalArgumentException(msg);
    }
    conditionValue = xescapeFullTextSearchValue(conditionValue);
    xgetSqlClause().beginOrScopeQuery();
    try {
        for (ColumnInfo columnInfo : textColumnList) {
            if (columnInfo == null) {
                continue;
            }
            final String tableOfColumn = columnInfo.getDBMeta().getTableDbName();
            if (!tableOfColumn.equalsIgnoreCase(asTableDbName())) {
                String msg = "The table of the text column should be '" + asTableDbName() + "'";
                msg = msg + " but the table is '" + tableOfColumn + "': column=" + columnInfo;
                throw new IllegalArgumentException(msg);
            }
            if (!columnInfo.isObjectNativeTypeString()) {
                String msg = "The text column should be String type:";
                msg = msg + " column=" + columnInfo;
                throw new IllegalArgumentException(msg);
            }
            invokeQueryLikeSearch(columnInfo.getColumnDbName(), conditionValue, xcreateMatchLikeSearch());
        }
    } finally {
        xgetSqlClause().endOrScopeQuery();
    }
}
Also used : ColumnInfo(org.dbflute.dbmeta.info.ColumnInfo)

Example 58 with ColumnInfo

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

the class AbstractConditionQuery method xregOutJo.

protected void xregOutJo(String prop) {
    // should be called after registration
    if (_queryRelationKeepingMap == null) {
        // no way, just in case
        _queryRelationKeepingMap = newLinkedHashMapSized(4);
    }
    final ConditionQuery cq = _queryRelationKeepingMap.get(prop);
    if (cq == null) {
        // no way, just in case
        String msg = "Not found the condition-query for (Query)Relation: " + prop;
        throw new IllegalStateException(msg);
    }
    final ForeignInfo foreignInfo = xgetLocalDBMeta().findForeignInfo(prop);
    final Map<ColumnInfo, ColumnInfo> localForeignColMap = foreignInfo.getLocalForeignColumnInfoMap();
    final Map<String, String> joinOnMap = newLinkedHashMapSized(localForeignColMap.size());
    for (Entry<ColumnInfo, ColumnInfo> entry : localForeignColMap.entrySet()) {
        final ColumnInfo localCol = entry.getKey();
        final ColumnInfo foreignCol = entry.getValue();
        joinOnMap.put(localCol.getColumnDbName(), foreignCol.getColumnDbName());
    }
    registerOuterJoin(cq, joinOnMap, prop);
}
Also used : ForeignInfo(org.dbflute.dbmeta.info.ForeignInfo) ColumnInfo(org.dbflute.dbmeta.info.ColumnInfo)

Example 59 with ColumnInfo

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

the class AbstractConditionQuery method setupConditionValueAndRegisterWhereClause.

protected void setupConditionValueAndRegisterWhereClause(ConditionKey key, Object value, ConditionValue cvalue, String columnDbName, ConditionOption option) {
    final DBMeta dbmeta = xgetLocalDBMeta();
    final ColumnInfo columnInfo = dbmeta.findColumnInfo(columnDbName);
    final QueryModeProvider queryModeProvider = xcreateQueryModeProvider();
    final Object filtered = filterConditionValueIfNeeds(key, value, cvalue, columnDbName, option, columnInfo);
    final String propertyName = columnInfo.getPropertyName();
    final String uncapPropName = initUncap(propertyName);
    // if Java, it is necessary to use uncapPropName
    final String location = xgetLocation(uncapPropName);
    key.setupConditionValue(queryModeProvider, cvalue, filtered, location, option);
    final ColumnRealName columnRealName = toColumnRealName(columnDbName);
    final ColumnFunctionCipher cipher = xgetSqlClause().findColumnFunctionCipher(columnInfo);
    final String usedAliasName = xgetAliasName();
    xgetSqlClause().registerWhereClause(columnRealName, key, cvalue, cipher, option, usedAliasName);
}
Also used : DBMeta(org.dbflute.dbmeta.DBMeta) ColumnInfo(org.dbflute.dbmeta.info.ColumnInfo) ColumnFunctionCipher(org.dbflute.cbean.cipher.ColumnFunctionCipher) ColumnRealName(org.dbflute.dbmeta.name.ColumnRealName) QueryModeProvider(org.dbflute.cbean.cvalue.ConditionValue.QueryModeProvider)

Example 60 with ColumnInfo

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

the class AbstractConditionQuery method xcreateInvalidQueryInfo.

protected HpInvalidQueryInfo xcreateInvalidQueryInfo(ConditionKey key, Object value, String columnDbName) {
    final String locationBase = xgetLocationBase();
    final ColumnInfo targetColumn = xgetLocalDBMeta().findColumnInfo(columnDbName);
    final HpInvalidQueryInfo invalidQueryInfo = new HpInvalidQueryInfo(locationBase, targetColumn, key, value);
    if (_inline) {
        invalidQueryInfo.inlineView();
    } else if (_onClause) {
        invalidQueryInfo.onClause();
    }
    return invalidQueryInfo;
}
Also used : HpInvalidQueryInfo(org.dbflute.cbean.chelper.HpInvalidQueryInfo) 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