use of org.dbflute.dbmeta.DBMeta in project dbflute-core by dbflute.
the class AbstractSqlClause method resolveRelationNo.
/**
* {@inheritDoc}
*/
public int resolveRelationNo(String localTableName, String foreignPropertyName) {
final DBMeta dbmeta = findDBMeta(localTableName);
final ForeignInfo foreignInfo = dbmeta.findForeignInfo(foreignPropertyName);
return foreignInfo.getRelationNo();
}
use of org.dbflute.dbmeta.DBMeta in project dbflute-core by dbflute.
the class SqlClauseOracle method lockForUpdate.
// ===================================================================================
// Lock Override
// =============
/**
* {@inheritDoc}
*/
public void lockForUpdate() {
final DBMeta dbmeta = findDBMeta(_tableDbName);
final String basePointAliasName = getBasePointAliasName();
if (dbmeta.hasPrimaryKey()) {
final ColumnSqlName primaryKeyName = dbmeta.getPrimaryInfo().getFirstColumn().getColumnSqlName();
_lockSqlSuffix = " for update of " + basePointAliasName + "." + primaryKeyName;
} else {
final ColumnSqlName randomColumnName = ((ColumnInfo) dbmeta.getColumnInfoList().get(0)).getColumnSqlName();
_lockSqlSuffix = " for update of " + basePointAliasName + "." + randomColumnName;
}
}
use of org.dbflute.dbmeta.DBMeta 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);
}
use of org.dbflute.dbmeta.DBMeta 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.dbmeta.DBMeta 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