use of org.dbflute.cbean.cipher.GearedCipherManager in project dbflute-core by dbflute.
the class AbstractConditionQuery method doRegisterQueryDerivedReferrer.
protected void doRegisterQueryDerivedReferrer(String function, final ConditionQuery subQuery, String columnDbName, String relatedColumnDbName, String propertyName, String referrerPropertyName, String operand, Object value, String parameterPropertyName, DerivedReferrerOption option) {
assertFunctionNotNull("QueryDerivedReferrer", columnDbName, function);
assertSubQueryNotNull("QueryDerivedReferrer", columnDbName, subQuery);
option.xacceptBaseCB(xgetBaseCB());
if (isDerivedReferrerSelectAllPossible(subQuery, option)) {
createCBExThrower().throwQueryDerivedReferrerSelectAllPossibleException(function, subQuery);
}
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 String mainSubQueryIdentity = propertyName + "[" + subQueryLevel + ":subquerymain]";
final String parameterPath = xgetLocation(parameterPropertyName);
final QueryDerivedReferrer derivedReferrer = option.createQueryDerivedReferrer(subQueryPath, localRealNameProvider, subQuerySqlNameProvider, subQueryLevel, subQueryClause, subQueryIdentity, subQueryDBMeta, cipherManager, mainSubQueryIdentity, operand, value, parameterPath);
xregisterParameterOption(option);
final String correlatedFixedCondition = xbuildReferrerCorrelatedFixedCondition(subQuery, referrerPropertyName);
final String clause = derivedReferrer.buildDerivedReferrer(function, columnDbName, relatedColumnDbName, correlatedFixedCondition, option);
// /= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
// is null or null-revived conversion (coalesce) -> 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 (select max(pc.PURCHASE_PRICE)
// from PURCHASE pc
// where pc.MEMBER_ID = wd.MEMBER_ID -- may null
// ) is null
// order by mb.MEMBER_ID
//
// and using coalesce means it may select records that have null value
// so using coalesce is no way in spite of operand
// = = = = = = = = = =/
final boolean noWayInner = HpQDRParameter.isOperandIsNull(operand) || option.mayNullRevived();
registerWhereClause(clause, noWayInner);
}
use of org.dbflute.cbean.cipher.GearedCipherManager in project dbflute-core by dbflute.
the class AbstractConditionQuery method registerInScopeRelation.
// *unsupported ExistsReferrer as in-line because it's (or was) so dangerous
// ===================================================================================
// InScopeRelation
// ===============
// {Modified at DBFlute-0.7.5}
protected void registerInScopeRelation(final ConditionQuery subQuery, String columnDbName, String relatedColumnDbName, String propertyName, String relationPropertyName, boolean notInScope) {
assertSubQueryNotNull("InScopeRelation", columnDbName, subQuery);
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 boolean suppressLocalAliasName = isInScopeRelationSuppressLocalAliasName();
final InScopeRelation inScopeRelation = new InScopeRelation(subQueryPath, localRealNameProvider, subQuerySqlNameProvider, subQueryLevel, subQueryClause, subQueryIdentity, subQueryDBMeta, cipherManager, suppressLocalAliasName);
final String correlatedFixedCondition = xbuildForeignCorrelatedFixedCondition(subQuery, relationPropertyName);
final String inScopeOption = notInScope ? "not" : null;
final String clause = inScopeRelation.buildInScopeRelation(columnDbName, relatedColumnDbName, correlatedFixedCondition, inScopeOption);
registerWhereClause(clause);
}
use of org.dbflute.cbean.cipher.GearedCipherManager in project dbflute-core by dbflute.
the class ResourceContext method findColumnFunctionCipher.
public static ColumnFunctionCipher findColumnFunctionCipher(String tableDbName, String columnDbName) {
assertResourceContextExists();
final ResourceContext context = getResourceContextOnThread();
final GearedCipherManager manager = context.getGearedCipherManager();
return manager != null ? manager.findColumnFunctionCipher(tableDbName, columnDbName) : null;
}
use of org.dbflute.cbean.cipher.GearedCipherManager in project dbflute-core by dbflute.
the class AbstractConditionQuery method doRegisterSpecifyDerivedReferrer.
protected void doRegisterSpecifyDerivedReferrer(String function, final ConditionQuery subQuery, String columnDbName, String relatedColumnDbName, String propertyName, String referrerPropertyName, String aliasName, DerivedReferrerOption option) {
assertFunctionNotNull("SpecifyDerivedReferrer", columnDbName, function);
assertSubQueryNotNull("SpecifyDerivedReferrer", columnDbName, subQuery);
option.xacceptBaseCB(xgetBaseCB());
if (isDerivedReferrerSelectAllPossible(subQuery, option)) {
createCBExThrower().throwSpecifyDerivedReferrerSelectAllPossibleException(function, subQuery, aliasName);
}
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 String mainSubQueryIdentity = propertyName + "[" + subQueryLevel + ":subquerymain]";
final SpecifyDerivedReferrer derivedReferrer = option.createSpecifyDerivedReferrer(subQueryPath, localRealNameProvider, subQuerySqlNameProvider, subQueryLevel, subQueryClause, subQueryIdentity, subQueryDBMeta, cipherManager, mainSubQueryIdentity, aliasName);
xregisterParameterOption(option);
final String correlatedFixedCondition = xbuildReferrerCorrelatedFixedCondition(subQuery, referrerPropertyName);
final String clause = derivedReferrer.buildDerivedReferrer(function, columnDbName, relatedColumnDbName, correlatedFixedCondition, option);
final HpDerivingSubQueryInfo subQueryInfo = xcreateDerivingSubQueryInfo(function, aliasName, clause, derivedReferrer);
xgetSqlClause().specifyDerivingSubQuery(subQueryInfo);
}
use of org.dbflute.cbean.cipher.GearedCipherManager in project dbflute-core by dbflute.
the class AbstractConditionQuery method doRegisterScalarCondition.
protected <CB extends ConditionBean> void doRegisterScalarCondition(final String function, final ConditionQuery subQuery, String propertyName, String operand, final HpSLCCustomized<CB> after, ScalarConditionOption option) {
assertSubQueryNotNull("ScalarCondition", propertyName, subQuery);
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 String mainSubQueryIdentity = propertyName + "[" + subQueryLevel + ":subquerymain]";
final PartitionByProvider partitionByProvider = () -> after.preparePartitionBySqlClause();
final ScalarCondition scalarCondition = new ScalarCondition(subQueryPath, localRealNameProvider, subQuerySqlNameProvider, subQueryLevel, subQueryClause, subQueryIdentity, subQueryDBMeta, cipherManager, mainSubQueryIdentity, operand, partitionByProvider);
xregisterParameterOption(option);
final QueryClause clause = new QueryClause() {
/* lazy registration to use partition-by */
public String toString() {
return scalarCondition.buildScalarCondition(function, option);
}
};
// no speak about inner-join because of no possible of null revival
final QueryUsedAliasInfo usedAliasInfo = new QueryUsedAliasInfo(xgetAliasName(), null);
registerWhereClause(clause, usedAliasInfo);
}
Aggregations