use of org.dbflute.cbean.cipher.GearedCipherManager 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);
}
use of org.dbflute.cbean.cipher.GearedCipherManager in project dbflute-core by dbflute.
the class ConditionKey method doResolveCompoundColumnCipher.
protected ColumnRealName doResolveCompoundColumnCipher(ConditionOption option, SpecifiedColumn specifiedColumn) {
final GearedCipherManager cipherManager = option.getGearedCipherManager();
final ColumnRealName specifiedName = specifiedColumn.toColumnRealName();
if (cipherManager != null && !specifiedColumn.isDerived()) {
final ColumnInfo columnInfo = specifiedColumn.getColumnInfo();
final ColumnFunctionCipher cipher = cipherManager.findColumnFunctionCipher(columnInfo);
if (cipher != null) {
return toColumnRealName(cipher.decrypt(specifiedName.toString()));
} else {
return specifiedName;
}
} else {
return specifiedName;
}
}
Aggregations