Search in sources :

Example 56 with DBMeta

use of org.dbflute.dbmeta.DBMeta in project dbflute-core by dbflute.

the class AbstractConditionQuery method throwLikeSearchOptionNotFoundException.

protected void throwLikeSearchOptionNotFoundException(String columnDbName, String value) {
    final DBMeta dbmeta = xgetDBMetaProvider().provideDBMeta(asTableDbName());
    createCBExThrower().throwLikeSearchOptionNotFoundException(columnDbName, value, dbmeta);
}
Also used : DBMeta(org.dbflute.dbmeta.DBMeta)

Example 57 with DBMeta

use of org.dbflute.dbmeta.DBMeta 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 58 with DBMeta

use of org.dbflute.dbmeta.DBMeta in project dbflute-core by dbflute.

the class AbstractConditionQuery method invokeValue.

// ===================================================================================
// Reflection Invoking
// ===================
/**
 * {@inheritDoc}
 */
public ConditionValue invokeValue(String columnFlexibleName) {
    assertStringNotNullAndNotTrimmedEmpty("columnFlexibleName", columnFlexibleName);
    final DBMeta dbmeta = xgetLocalDBMeta();
    final String columnCapPropName = initCap(dbmeta.findColumnInfo(columnFlexibleName).getPropertyName());
    final String methodName = "xdfget" + columnCapPropName;
    final Method method = xhelpGettingCQMethod(this, methodName, (Class<?>[]) null);
    if (method == null) {
        throwConditionInvokingGetMethodNotFoundException(columnFlexibleName, methodName);
        // unreachable
        return null;
    }
    try {
        return (ConditionValue) xhelpInvokingCQMethod(this, method, (Object[]) null);
    } catch (ReflectionFailureException e) {
        throwConditionInvokingGetReflectionFailureException(columnFlexibleName, methodName, e);
        // unreachable
        return null;
    }
}
Also used : DBMeta(org.dbflute.dbmeta.DBMeta) ConditionValue(org.dbflute.cbean.cvalue.ConditionValue) Method(java.lang.reflect.Method) ReflectionFailureException(org.dbflute.util.DfReflectionUtil.ReflectionFailureException)

Example 59 with DBMeta

use of org.dbflute.dbmeta.DBMeta in project dbflute-core by dbflute.

the class AbstractConditionQuery method registerOuterJoin.

// ===================================================================================
// Outer Join
// ==========
/**
 * Register outer-join. <br>
 * Optional info, fixed condition and fixed in-line, are resolved in this method.
 * @param foreignCQ The condition-query for foreign table. (NotNull)
 * @param joinOnResourceMap The resource map of join condition on on-clause. (NotNull)
 * @param foreignPropertyName The property name of foreign relation corresponding to this join. (NotNull)
 */
protected void registerOuterJoin(ConditionQuery foreignCQ, Map<String, String> joinOnResourceMap, String foreignPropertyName) {
    final DBMeta dbmeta = xgetLocalDBMeta();
    final ForeignInfo foreignInfo = dbmeta.findForeignInfo(foreignPropertyName);
    doRegisterOuterJoin(foreignCQ, joinOnResourceMap, foreignPropertyName, foreignInfo);
}
Also used : ForeignInfo(org.dbflute.dbmeta.info.ForeignInfo) DBMeta(org.dbflute.dbmeta.DBMeta)

Example 60 with DBMeta

use of org.dbflute.dbmeta.DBMeta in project dbflute-core by dbflute.

the class AbstractConditionQuery method registerExistsReferrer.

protected void registerExistsReferrer(final ConditionQuery subQuery, String columnDbName, String relatedColumnDbName, String propertyName, String referrerPropertyName, boolean notExists) {
    assertSubQueryNotNull("ExistsReferrer", relatedColumnDbName, subQuery);
    if (subQuery.xgetSqlClause().isUseInScopeSubQueryForExistsReferrer()) {
        registerInScopeRelation(subQuery, columnDbName, relatedColumnDbName, propertyName, referrerPropertyName, notExists);
        return;
    }
    final SubQueryPath subQueryPath = new SubQueryPath(xgetLocation(propertyName));
    final GeneralColumnRealNameProvider localRealNameProvider = new GeneralColumnRealNameProvider();
    final int subQueryLevel = subQuery.xgetSqlClause().getSubQueryLevel();
    final SqlClause subQueryClause = subQuery.xgetSqlClause();
    final String subQueryIdentity = propertyName + "[" + subQueryLevel + "]";
    final ColumnSqlNameProvider subQuerySqlNameProvider = dbName -> subQuery.toColumnSqlName(dbName);
    final DBMeta subQueryDBMeta = findDBMeta(subQuery.asTableDbName());
    final GearedCipherManager cipherManager = xgetSqlClause().getGearedCipherManager();
    final ExistsReferrer existsReferrer = new ExistsReferrer(subQueryPath, localRealNameProvider, subQuerySqlNameProvider, subQueryLevel, subQueryClause, subQueryIdentity, subQueryDBMeta, cipherManager);
    final String correlatedFixedCondition = xbuildReferrerCorrelatedFixedCondition(subQuery, referrerPropertyName);
    final String existsOption = notExists ? "not" : null;
    final String clause = existsReferrer.buildExistsReferrer(columnDbName, relatedColumnDbName, correlatedFixedCondition, existsOption);
    // /= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
    // Exists -> possible to be inner
    // NotExists -> no way to be inner
    // 
    // for example, the following SQL is no way to be inner
    // (suppose if PURCHASE refers WITHDRAWAL)
    // 
    // select mb.MEMBER_ID, mb.MEMBER_NAME
    // , mb.MEMBER_STATUS_CODE, wd.MEMBER_ID as WD_MEMBER_ID
    // from MEMBER mb
    // left outer join MEMBER_WITHDRAWAL wd on mb.MEMBER_ID = wd.MEMBER_ID
    // where not exists (select pc.PURCHASE_ID
    // from PURCHASE pc
    // where pc.MEMBER_ID = wd.MEMBER_ID
    // )
    // order by mb.MEMBER_ID
    // = = = = = = = = = =/
    // but 'exists' allowed
    final boolean noWayInner = notExists;
    registerWhereClause(clause, noWayInner);
}
Also used : ColumnRealNameProvider(org.dbflute.dbmeta.name.ColumnRealNameProvider) DerivedReferrerOptionFactory(org.dbflute.cbean.coption.DerivedReferrerOptionFactory) UnionClauseProvider(org.dbflute.cbean.sqlclause.union.UnionClauseProvider) SpecifiedColumn(org.dbflute.cbean.dream.SpecifiedColumn) ConditionKeyInScope(org.dbflute.cbean.ckey.ConditionKeyInScope) Date(java.util.Date) ParameterOption(org.dbflute.cbean.coption.ParameterOption) LoggerFactory(org.slf4j.LoggerFactory) OrderByElement(org.dbflute.cbean.sqlclause.orderby.OrderByElement) QueryClause(org.dbflute.cbean.sqlclause.query.QueryClause) ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) ColumnSqlNameProvider(org.dbflute.dbmeta.name.ColumnSqlNameProvider) SimpleMapPmb(org.dbflute.twowaysql.pmbean.SimpleMapPmb) ColumnRealName(org.dbflute.dbmeta.name.ColumnRealName) PrimaryInfo(org.dbflute.dbmeta.info.PrimaryInfo) OrScopeQueryAndPartUnsupportedOperationException(org.dbflute.exception.OrScopeQueryAndPartUnsupportedOperationException) Map(java.util.Map) HpInvalidQueryInfo(org.dbflute.cbean.chelper.HpInvalidQueryInfo) DfBeanDescFactory(org.dbflute.helper.beans.factory.DfBeanDescFactory) ManualOrderOption(org.dbflute.cbean.ordering.ManualOrderOption) ConditionOption(org.dbflute.cbean.coption.ConditionOption) FixedConditionLazyChecker(org.dbflute.cbean.sqlclause.join.FixedConditionLazyChecker) Method(java.lang.reflect.Method) RangeOfOption(org.dbflute.cbean.coption.RangeOfOption) DfCollectionUtil(org.dbflute.util.DfCollectionUtil) SubQuery(org.dbflute.cbean.scoping.SubQuery) TimeZone(java.util.TimeZone) IndependentProcessor(org.dbflute.helper.function.IndependentProcessor) Timestamp(java.sql.Timestamp) Collection(java.util.Collection) LikeSearchOption(org.dbflute.cbean.coption.LikeSearchOption) QueryModeProvider(org.dbflute.cbean.cvalue.ConditionValue.QueryModeProvider) FixedConditionResolver(org.dbflute.cbean.sqlclause.join.FixedConditionResolver) ScalarConditionOption(org.dbflute.cbean.coption.ScalarConditionOption) DBMeta(org.dbflute.dbmeta.DBMeta) FunCustodial(org.dbflute.FunCustodial) DfBeanDesc(org.dbflute.helper.beans.DfBeanDesc) Classification(org.dbflute.jdbc.Classification) List(java.util.List) ColumnInfo(org.dbflute.dbmeta.info.ColumnInfo) ExistsReferrer(org.dbflute.cbean.sqlclause.subquery.ExistsReferrer) LocalDate(java.time.LocalDate) Entry(java.util.Map.Entry) SqlClauseMySql(org.dbflute.cbean.sqlclause.SqlClauseMySql) DBMetaProvider(org.dbflute.dbmeta.DBMetaProvider) DBFluteSystem(org.dbflute.system.DBFluteSystem) ColumnFunctionCipher(org.dbflute.cbean.cipher.ColumnFunctionCipher) DateConditionAdjuster(org.dbflute.cbean.garnish.datefitting.DateConditionAdjuster) ConditionKeyPrepareResult(org.dbflute.cbean.ckey.ConditionKeyPrepareResult) ScalarCondition(org.dbflute.cbean.sqlclause.subquery.ScalarCondition) HpFixedConditionQueryResolver(org.dbflute.cbean.chelper.HpFixedConditionQueryResolver) LocalDateTime(java.time.LocalDateTime) IllegalConditionBeanOperationException(org.dbflute.exception.IllegalConditionBeanOperationException) HashMap(java.util.HashMap) ReflectionFailureException(org.dbflute.util.DfReflectionUtil.ReflectionFailureException) DerivedReferrerOption(org.dbflute.cbean.coption.DerivedReferrerOption) ManualOrderOptionCall(org.dbflute.cbean.ordering.ManualOrderOptionCall) GearedCipherManager(org.dbflute.cbean.cipher.GearedCipherManager) ConditionInvokingFailureException(org.dbflute.exception.ConditionInvokingFailureException) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) SqlClauseOracle(org.dbflute.cbean.sqlclause.SqlClauseOracle) HpQDRSetupper(org.dbflute.cbean.chelper.HpQDRSetupper) ExtensionOperand(org.dbflute.dbway.ExtensionOperand) HpQDRParameter(org.dbflute.cbean.chelper.HpQDRParameter) PartitionByProvider(org.dbflute.cbean.sqlclause.subquery.ScalarCondition.PartitionByProvider) DfReflectionUtil(org.dbflute.util.DfReflectionUtil) QueryUsedAliasInfo(org.dbflute.cbean.sqlclause.query.QueryUsedAliasInfo) ShortCharHandlingMode(org.dbflute.jdbc.ShortCharHandlingMode) Srl(org.dbflute.util.Srl) QueryClauseArranger(org.dbflute.cbean.sqlclause.query.QueryClauseArranger) ColumnSqlName(org.dbflute.dbmeta.name.ColumnSqlName) ConditionValue(org.dbflute.cbean.cvalue.ConditionValue) RelationInfo(org.dbflute.dbmeta.info.RelationInfo) ForeignInfo(org.dbflute.dbmeta.info.ForeignInfo) FromToOption(org.dbflute.cbean.coption.FromToOption) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) HpSLCFunction(org.dbflute.cbean.chelper.HpSLCFunction) SpecifyDerivedReferrer(org.dbflute.cbean.sqlclause.subquery.SpecifyDerivedReferrer) WayOfMySQL(org.dbflute.dbway.WayOfMySQL) QueryDerivedReferrer(org.dbflute.cbean.sqlclause.subquery.QueryDerivedReferrer) ConditionKey(org.dbflute.cbean.ckey.ConditionKey) ConditionOptionCall(org.dbflute.cbean.coption.ConditionOptionCall) HpSLCCustomized(org.dbflute.cbean.chelper.HpSLCCustomized) ConditionBeanExceptionThrower(org.dbflute.cbean.exception.ConditionBeanExceptionThrower) HpDerivingSubQueryInfo(org.dbflute.cbean.chelper.HpDerivingSubQueryInfo) SubQueryPath(org.dbflute.cbean.sqlclause.subquery.SubQueryPath) ReferrerInfo(org.dbflute.dbmeta.info.ReferrerInfo) DfTypeUtil(org.dbflute.util.DfTypeUtil) HpQDRFunction(org.dbflute.cbean.chelper.HpQDRFunction) SqlClause(org.dbflute.cbean.sqlclause.SqlClause) InScopeRelation(org.dbflute.cbean.sqlclause.subquery.InScopeRelation) ExistsReferrer(org.dbflute.cbean.sqlclause.subquery.ExistsReferrer) DBMeta(org.dbflute.dbmeta.DBMeta) SubQueryPath(org.dbflute.cbean.sqlclause.subquery.SubQueryPath) SqlClause(org.dbflute.cbean.sqlclause.SqlClause) ColumnSqlNameProvider(org.dbflute.dbmeta.name.ColumnSqlNameProvider) GearedCipherManager(org.dbflute.cbean.cipher.GearedCipherManager)

Aggregations

DBMeta (org.dbflute.dbmeta.DBMeta)64 ColumnInfo (org.dbflute.dbmeta.info.ColumnInfo)32 ArrayList (java.util.ArrayList)13 ForeignInfo (org.dbflute.dbmeta.info.ForeignInfo)13 List (java.util.List)12 LinkedHashMap (java.util.LinkedHashMap)11 ColumnSqlName (org.dbflute.dbmeta.name.ColumnSqlName)10 Entity (org.dbflute.Entity)9 PrimaryInfo (org.dbflute.dbmeta.info.PrimaryInfo)9 ReferrerInfo (org.dbflute.dbmeta.info.ReferrerInfo)9 Method (java.lang.reflect.Method)8 ReflectionFailureException (org.dbflute.util.DfReflectionUtil.ReflectionFailureException)8 Map (java.util.Map)7 ColumnFunctionCipher (org.dbflute.cbean.cipher.ColumnFunctionCipher)7 RelationInfo (org.dbflute.dbmeta.info.RelationInfo)7 LocalDate (java.time.LocalDate)6 LocalDateTime (java.time.LocalDateTime)6 Collection (java.util.Collection)6 Date (java.util.Date)6 HashMap (java.util.HashMap)6