Search in sources :

Example 21 with DBMeta

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

the class AbstractConditionBean method xdoSetupSelectDreamCruiseJourneyLogBook.

protected void xdoSetupSelectDreamCruiseJourneyLogBook() {
    // small waste exists but simple logic is best here
    final ConditionBean departurePort = xgetDreamCruiseDeparturePort();
    for (String relationPath : _dreamCruiseJourneyLogBook) {
        // e.g. _2_5
        final List<String> relNoExpList = Srl.splitList(relationPath, "_");
        final StringBuilder sb = new StringBuilder();
        DBMeta currentMeta = asDBMeta();
        int index = 0;
        for (String relNoExp : relNoExpList) {
            if ("".equals(relNoExp)) {
                continue;
            }
            final Integer relationNo = Integer.valueOf(relNoExp);
            final ForeignInfo foreignInfo = currentMeta.findForeignInfo(relationNo);
            final String foreignPropertyName = foreignInfo.getForeignPropertyName();
            if (index > 0) {
                sb.append(".");
            }
            sb.append(foreignPropertyName);
            currentMeta = foreignInfo.getForeignDBMeta();
            ++index;
        }
        departurePort.invokeSetupSelect(sb.toString());
    }
}
Also used : ForeignInfo(org.dbflute.dbmeta.info.ForeignInfo) DBMeta(org.dbflute.dbmeta.DBMeta)

Example 22 with DBMeta

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

the class AbstractConditionQuery method xbuildForeignCorrelatedFixedCondition.

protected String xbuildForeignCorrelatedFixedCondition(ConditionQuery subQuery, String relationPropertyName) {
    if (relationPropertyName == null) {
        return null;
    }
    final DBMeta localDBMeta = xgetLocalDBMeta();
    final RelationInfo relationInfo = localDBMeta.findRelationInfo(relationPropertyName);
    if (!relationInfo.isReferrer()) {
        return null;
    }
    if (!(relationInfo instanceof ReferrerInfo)) {
        return null;
    }
    final ReferrerInfo referrerInfo = (ReferrerInfo) relationInfo;
    return xdoBuildReferrerCorrelatedFixedCondition(subQuery, referrerInfo);
}
Also used : DBMeta(org.dbflute.dbmeta.DBMeta) RelationInfo(org.dbflute.dbmeta.info.RelationInfo) ReferrerInfo(org.dbflute.dbmeta.info.ReferrerInfo)

Example 23 with DBMeta

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

the class AbstractConditionQuery method doRegIQ.

protected void doRegIQ(ConditionKey key, Object value, ConditionValue cvalue, String columnDbName, ConditionOption option) {
    if (!prepareQueryChecked(key, value, cvalue, columnDbName).newClause()) {
        return;
    }
    final DBMeta dbmeta = xgetDBMetaProvider().provideDBMetaChecked(asTableDbName());
    final ColumnInfo columnInfo = dbmeta.findColumnInfo(columnDbName);
    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(xcreateQueryModeProvider(), cvalue, value, location, option);
    final ColumnSqlName columnSqlName = columnInfo.getColumnSqlName();
    final ColumnFunctionCipher cipher = xgetSqlClause().findColumnFunctionCipher(columnInfo);
    if (isBaseQuery()) {
        xgetSqlClause().registerBaseTableInlineWhereClause(columnSqlName, key, cvalue, cipher, option);
    } else {
        final String aliasName = xgetAliasName();
        xgetSqlClause().registerOuterJoinInlineWhereClause(aliasName, columnSqlName, key, cvalue, cipher, option, _onClause);
    }
}
Also used : ColumnSqlName(org.dbflute.dbmeta.name.ColumnSqlName) DBMeta(org.dbflute.dbmeta.DBMeta) ColumnInfo(org.dbflute.dbmeta.info.ColumnInfo) ColumnFunctionCipher(org.dbflute.cbean.cipher.ColumnFunctionCipher)

Example 24 with DBMeta

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

the class HpAbstractSpecification method getColumnInfoList.

// -----------------------------------------------------
// Assist Helper
// -------------
protected List<ColumnInfo> getColumnInfoList() {
    final String tableDbName = _query.asTableDbName();
    final DBMeta dbmeta = _dbmetaProvider.provideDBMeta(tableDbName);
    return dbmeta.getColumnInfoList();
}
Also used : DBMeta(org.dbflute.dbmeta.DBMeta)

Example 25 with DBMeta

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

the class DateUpdateAdjuster method truncatePrecisionOfEntityProperty.

// ===================================================================================
// DatetimePrecision Truncation
// ============================
/**
 * @param entity The entity to be adjusted here. (NotNull)
 */
public void truncatePrecisionOfEntityProperty(Entity entity) {
    if (entity == null) {
        throw new IllegalArgumentException("The argument 'entity' should not be null.");
    }
    final DBMeta dbmeta = entity.asDBMeta();
    final List<ColumnInfo> columnInfoList = dbmeta.getColumnInfoList();
    final boolean createdBySelect = entity.createdBySelect();
    if (createdBySelect) {
        // to avoid non-specified column check
        entity.clearMarkAsSelect();
    }
    try {
        for (ColumnInfo columnInfo : columnInfoList) {
            if (columnInfo.isObjectNativeTypeDate()) {
                // it does not need to read/write if LocalDate, but no-if to be simple
                // (and read/write by columnInfo does not use reflection so no worry)
                // is date
                final Object dateValue = columnInfo.read(entity);
                if (dateValue != null) {
                    columnInfo.write(entity, doTruncatePrecisionIfHasTime(columnInfo, dateValue));
                }
            }
        }
    } finally {
        if (createdBySelect) {
            // restore
            entity.markAsSelect();
        }
    }
}
Also used : DBMeta(org.dbflute.dbmeta.DBMeta) ColumnInfo(org.dbflute.dbmeta.info.ColumnInfo)

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