Search in sources :

Example 6 with TnBeanMetaData

use of org.dbflute.s2dao.metadata.TnBeanMetaData in project dbflute-core by dbflute.

the class TnAbstractEntityDynamicCommand method setupUpdateWhere.

protected void setupUpdateWhere(StringBuilder sb, Set<String> uniqueDrivenPropSet, boolean optimisticLockHandling) {
    final TnBeanMetaData bmd = _beanMetaData;
    sb.append(" where ");
    prepareWherePrimaryKey(sb, uniqueDrivenPropSet);
    if (optimisticLockHandling && bmd.hasVersionNoPropertyType()) {
        final TnPropertyType pt = bmd.getVersionNoPropertyType();
        sb.append(" and ").append(pt.getColumnSqlName()).append(" = ?");
    }
    if (optimisticLockHandling && bmd.hasTimestampPropertyType()) {
        final TnPropertyType pt = bmd.getTimestampPropertyType();
        sb.append(" and ").append(pt.getColumnSqlName()).append(" = ?");
    }
}
Also used : TnBeanMetaData(org.dbflute.s2dao.metadata.TnBeanMetaData) TnPropertyType(org.dbflute.s2dao.metadata.TnPropertyType)

Example 7 with TnBeanMetaData

use of org.dbflute.s2dao.metadata.TnBeanMetaData in project dbflute-core by dbflute.

the class TnInsertEntityDynamicCommand method execute.

// ===================================================================================
// Execute
// =======
public Object execute(Object[] args) {
    final Object bean = extractBeanFromArgsChecked(args);
    final InsertOption<ConditionBean> option = extractInsertOptionChecked(args);
    prepareStatementConfigOnThreadIfExists(option);
    final TnBeanMetaData bmd = _beanMetaData;
    final TnPropertyType[] propertyTypes = createInsertPropertyTypes(bmd, bean, _propertyNames, option);
    final String sql = filterExecutedSql(createInsertSql(bmd, propertyTypes, option));
    return doExecute(bean, propertyTypes, sql, option);
}
Also used : TnBeanMetaData(org.dbflute.s2dao.metadata.TnBeanMetaData) ConditionBean(org.dbflute.cbean.ConditionBean) TnPropertyType(org.dbflute.s2dao.metadata.TnPropertyType)

Example 8 with TnBeanMetaData

use of org.dbflute.s2dao.metadata.TnBeanMetaData in project dbflute-core by dbflute.

the class TnAbstractEntityHandler method doSetupUpdateWhereBindVariables.

protected void doSetupUpdateWhereBindVariables(List<Object> varList, List<ValueType> varValueTypeList, Object bean, Set<String> uniqueDrivenPropSet) {
    final TnBeanMetaData bmd = getBeanMetaData();
    if (uniqueDrivenPropSet != null && !uniqueDrivenPropSet.isEmpty()) {
        for (String uniqueProp : uniqueDrivenPropSet) {
            final TnPropertyType pt = bmd.getPropertyType(uniqueProp);
            doRegisterUpdateWhereBindVariable(varList, varValueTypeList, bean, pt);
        }
    } else {
        for (int i = 0; i < bmd.getPrimaryKeySize(); ++i) {
            final TnPropertyType pt = bmd.getPropertyTypeByColumnName(bmd.getPrimaryKeyDbName(i));
            doRegisterUpdateWhereBindVariable(varList, varValueTypeList, bean, pt);
        }
    }
    if (_optimisticLockHandling && bmd.hasVersionNoPropertyType()) {
        final TnPropertyType pt = bmd.getVersionNoPropertyType();
        doRegisterUpdateWhereBindVariable(varList, varValueTypeList, bean, pt);
    }
    if (_optimisticLockHandling && bmd.hasTimestampPropertyType()) {
        final TnPropertyType pt = bmd.getTimestampPropertyType();
        doRegisterUpdateWhereBindVariable(varList, varValueTypeList, bean, pt);
    }
}
Also used : TnBeanMetaData(org.dbflute.s2dao.metadata.TnBeanMetaData) TnPropertyType(org.dbflute.s2dao.metadata.TnPropertyType)

Example 9 with TnBeanMetaData

use of org.dbflute.s2dao.metadata.TnBeanMetaData in project dbflute-core by dbflute.

the class TnRelationRowCreatorExtension method setupPropertyCache.

// ===================================================================================
// Property Cache Setup
// ====================
@Override
protected void setupPropertyCache(TnRelationRowCreationResource res) throws SQLException {
    // - - - - - - - - - - -
    if (res.isStopCurrentRelationMapping()) {
        return;
    }
    // set up property cache about current bean meta data
    final TnBeanMetaData nextBmd = res.getRelationBeanMetaData();
    final List<TnPropertyType> ptList = nextBmd.getPropertyTypeList();
    for (TnPropertyType pt : ptList) {
        // already been filtered as target only
        res.setCurrentPropertyType(pt);
        setupPropertyCacheElement(res);
    }
    // set up next level relation's property cache
    if (res.isStopNextRelationMapping()) {
        return;
    }
    res.prepareNextLevelMapping();
    try {
        setupNextPropertyCache(res, nextBmd);
    } finally {
        res.closeNextLevelMapping();
    }
}
Also used : TnBeanMetaData(org.dbflute.s2dao.metadata.TnBeanMetaData) TnPropertyType(org.dbflute.s2dao.metadata.TnPropertyType)

Example 10 with TnBeanMetaData

use of org.dbflute.s2dao.metadata.TnBeanMetaData in project dbflute-core by dbflute.

the class TnRelationRowCreatorExtension method setupNextRelationRow.

// -----------------------------------------------------
// Next Relation
// -------------
protected void setupNextRelationRow(TnRelationRowCreationResource res) throws SQLException {
    final TnBeanMetaData nextBmd = res.getRelationBeanMetaData();
    final Object row = res.getRow();
    res.prepareNextLevelMapping();
    try {
        final List<TnRelationPropertyType> nextRptList = nextBmd.getRelationPropertyTypeList();
        for (TnRelationPropertyType nextRpt : nextRptList) {
            setupNextRelationRowElement(res, row, nextRpt);
        }
    } finally {
        res.setRow(row);
        res.closeNextLevelMapping();
    }
}
Also used : TnRelationPropertyType(org.dbflute.s2dao.metadata.TnRelationPropertyType) TnBeanMetaData(org.dbflute.s2dao.metadata.TnBeanMetaData)

Aggregations

TnBeanMetaData (org.dbflute.s2dao.metadata.TnBeanMetaData)11 TnPropertyType (org.dbflute.s2dao.metadata.TnPropertyType)7 ArrayList (java.util.ArrayList)4 TnRelationPropertyType (org.dbflute.s2dao.metadata.TnRelationPropertyType)3 Timestamp (java.sql.Timestamp)2 Map (java.util.Map)2 ConditionBean (org.dbflute.cbean.ConditionBean)2 DBMeta (org.dbflute.dbmeta.DBMeta)2 ValueType (org.dbflute.jdbc.ValueType)2 List (java.util.List)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 DfPropertyDesc (org.dbflute.helper.beans.DfPropertyDesc)1 OutsideSqlContext (org.dbflute.outsidesql.OutsideSqlContext)1 TnIdentifierGenerator (org.dbflute.s2dao.identity.TnIdentifierGenerator)1 TnPropertyMapping (org.dbflute.s2dao.metadata.TnPropertyMapping)1 TnBeanMetaDataImpl (org.dbflute.s2dao.metadata.impl.TnBeanMetaDataImpl)1 TnRelationRowCache (org.dbflute.s2dao.rowcreator.TnRelationRowCache)1 TnRelationSelector (org.dbflute.s2dao.rowcreator.TnRelationSelector)1