Search in sources :

Example 6 with QueryClause

use of org.dbflute.cbean.sqlclause.query.QueryClause in project dbflute-core by dbflute.

the class AbstractSqlClause method registerWhereClause.

/**
 * {@inheritDoc}
 */
public void registerWhereClause(QueryClause clause, QueryUsedAliasInfo... usedAliasInfos) {
    assertObjectNotNull("clause", clause);
    assertObjectNotNull("usedAliasInfos", usedAliasInfos);
    if (usedAliasInfos.length == 0) {
        String msg = "The argument 'usedAliasInfos' should not be empty.";
        throw new IllegalArgumentException(msg);
    }
    final List<QueryClause> clauseList = getWhereClauseList4Register();
    doRegisterWhereClause(clauseList, clause);
    for (QueryUsedAliasInfo usedAliasInfo : usedAliasInfos) {
        reflectWhereUsedToJoin(usedAliasInfo);
    }
}
Also used : QueryUsedAliasInfo(org.dbflute.cbean.sqlclause.query.QueryUsedAliasInfo) QueryClause(org.dbflute.cbean.sqlclause.query.QueryClause) OrScopeQueryAndPartQueryClause(org.dbflute.cbean.sqlclause.query.OrScopeQueryAndPartQueryClause) StringQueryClause(org.dbflute.cbean.sqlclause.query.StringQueryClause)

Example 7 with QueryClause

use of org.dbflute.cbean.sqlclause.query.QueryClause in project dbflute-core by dbflute.

the class AbstractSqlClause method buildWhereClause.

protected void buildWhereClause(StringBuilder sb, boolean template) {
    final List<QueryClause> whereList = getWhereList();
    if (whereList.isEmpty()) {
        if (template) {
            sb.append(" ").append(getWhereClauseMark());
        }
        return;
    }
    int count = 0;
    for (QueryClause whereClause : whereList) {
        final String clauseElement = filterWhereClauseSimply(whereClause.toString());
        if (count == 0) {
            sb.append(ln()).append(" ");
            sb.append("where ").append(template ? getWhereFirstConditionMark() : "").append(clauseElement);
        } else {
            sb.append(ln()).append("  ");
            sb.append(" and ").append(clauseElement);
        }
        ++count;
    }
}
Also used : QueryClause(org.dbflute.cbean.sqlclause.query.QueryClause) OrScopeQueryAndPartQueryClause(org.dbflute.cbean.sqlclause.query.OrScopeQueryAndPartQueryClause) StringQueryClause(org.dbflute.cbean.sqlclause.query.StringQueryClause)

Example 8 with QueryClause

use of org.dbflute.cbean.sqlclause.query.QueryClause in project dbflute-core by dbflute.

the class AbstractSqlClause method buildJoinTableClause.

protected void buildJoinTableClause(StringBuilder sb, LeftOuterJoinInfo joinInfo, String joinExp, boolean canBeInnerJoin) {
    final String foreignTableDbName = joinInfo.getForeignTableDbName();
    // basically for in-line view indent
    final int tablePos = 3 + joinExp.length();
    final DBMeta foreignDBMeta = findDBMeta(foreignTableDbName);
    final TableSqlName foreignTableSqlName = foreignDBMeta.getTableSqlName();
    final List<QueryClause> inlineWhereClauseList = joinInfo.getInlineWhereClauseList();
    final String tableExp;
    if (inlineWhereClauseList.isEmpty()) {
        tableExp = foreignTableSqlName.toString();
    } else {
        tableExp = getInlineViewClause(foreignTableSqlName, inlineWhereClauseList, tablePos);
    }
    if (joinInfo.hasFixedCondition()) {
        sb.append(joinInfo.resolveFixedInlineView(tableExp, canBeInnerJoin));
    } else {
        sb.append(tableExp);
    }
}
Also used : DBMeta(org.dbflute.dbmeta.DBMeta) QueryClause(org.dbflute.cbean.sqlclause.query.QueryClause) OrScopeQueryAndPartQueryClause(org.dbflute.cbean.sqlclause.query.OrScopeQueryAndPartQueryClause) StringQueryClause(org.dbflute.cbean.sqlclause.query.StringQueryClause) TableSqlName(org.dbflute.dbmeta.name.TableSqlName)

Example 9 with QueryClause

use of org.dbflute.cbean.sqlclause.query.QueryClause in project dbflute-core by dbflute.

the class AbstractSqlClause method markOrScopeQueryAndPart.

protected void markOrScopeQueryAndPart(List<QueryClause> clauseList) {
    if (_orScopeQueryEffective && _orScopeQueryAndPartEffective && !clauseList.isEmpty()) {
        // as latest
        final QueryClause original = clauseList.remove(clauseList.size() - 1);
        clauseList.add(new OrScopeQueryAndPartQueryClause(original, _orScopeQueryAndPartIdentity));
    }
}
Also used : OrScopeQueryAndPartQueryClause(org.dbflute.cbean.sqlclause.query.OrScopeQueryAndPartQueryClause) QueryClause(org.dbflute.cbean.sqlclause.query.QueryClause) OrScopeQueryAndPartQueryClause(org.dbflute.cbean.sqlclause.query.OrScopeQueryAndPartQueryClause) StringQueryClause(org.dbflute.cbean.sqlclause.query.StringQueryClause)

Example 10 with QueryClause

use of org.dbflute.cbean.sqlclause.query.QueryClause in project dbflute-core by dbflute.

the class AbstractSqlClause method registerBaseTableInlineWhereClause.

// ===================================================================================
// In-line Where
// =============
// -----------------------------------------------------
// In-line for Base Table
// ----------------------
public // SQL name of column
void registerBaseTableInlineWhereClause(// SQL name of column
ColumnSqlName columnSqlName, // basic resources
ConditionKey key, // basic resources
ConditionValue value, ColumnFunctionCipher cipher, ConditionOption option) {
    // optional resources
    final List<QueryClause> clauseList = getBaseTableInlineWhereClauseList4Register();
    final String inlineBaseAlias = getInlineViewBasePointAlias();
    final ColumnRealName columnRealName = ColumnRealName.create(inlineBaseAlias, columnSqlName);
    doRegisterWhereClause(clauseList, columnRealName, key, value, cipher, option, true, false);
}
Also used : ColumnRealName(org.dbflute.dbmeta.name.ColumnRealName) QueryClause(org.dbflute.cbean.sqlclause.query.QueryClause) OrScopeQueryAndPartQueryClause(org.dbflute.cbean.sqlclause.query.OrScopeQueryAndPartQueryClause) StringQueryClause(org.dbflute.cbean.sqlclause.query.StringQueryClause)

Aggregations

QueryClause (org.dbflute.cbean.sqlclause.query.QueryClause)14 OrScopeQueryAndPartQueryClause (org.dbflute.cbean.sqlclause.query.OrScopeQueryAndPartQueryClause)11 StringQueryClause (org.dbflute.cbean.sqlclause.query.StringQueryClause)11 ColumnRealName (org.dbflute.dbmeta.name.ColumnRealName)3 QueryUsedAliasInfo (org.dbflute.cbean.sqlclause.query.QueryUsedAliasInfo)2 DBMeta (org.dbflute.dbmeta.DBMeta)2 ColumnInfo (org.dbflute.dbmeta.info.ColumnInfo)2 TableSqlName (org.dbflute.dbmeta.name.TableSqlName)2 Method (java.lang.reflect.Method)1 Timestamp (java.sql.Timestamp)1 LocalDate (java.time.LocalDate)1 LocalDateTime (java.time.LocalDateTime)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Map (java.util.Map)1