当前位置: 首页>>代码示例>>Java>>正文


Java DBMeta类代码示例

本文整理汇总了Java中org.dbflute.dbmeta.DBMeta的典型用法代码示例。如果您正苦于以下问题:Java DBMeta类的具体用法?Java DBMeta怎么用?Java DBMeta使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DBMeta类属于org.dbflute.dbmeta包,在下文中一共展示了DBMeta类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: prepareEntityUpdateKeyMap

import org.dbflute.dbmeta.DBMeta; //导入依赖的package包/类
protected Map<String, Object> prepareEntityUpdateKeyMap(BehaviorCommandMeta meta) {
    final Entity entity = extractArgumentEntity(meta); // always can get if entity update
    if (entity == null) { // no way, just in case
        return Collections.emptyMap();
    }
    final DBMeta dbmeta = entity.asDBMeta();
    final Map<String, Object> keyMap;
    final Set<String> uniqueProps = entity.myuniqueDrivenProperties();
    if (!uniqueProps.isEmpty()) {
        final Map<String, Object> uniqueMap = uniqueProps.stream().map(prop -> {
            return dbmeta.findColumnInfo(prop);
        }).collect(Collectors.toMap(col -> col.getColumnDbName(), col -> col.read(entity)));
        keyMap = uniqueMap;
    } else if (dbmeta.hasPrimaryKey() && entity.hasPrimaryKeyValue()) {
        keyMap = dbmeta.extractPrimaryKeyMap(entity);
    } else { // no way if entity update, just in case
        keyMap = Collections.emptyMap();
    }
    return keyMap;
}
 
开发者ID:lastaflute,项目名称:lastaflute,代码行数:21,代码来源:TransactionSavedRecentResult.java

示例2: initializeConditionBeanMetaData

import org.dbflute.dbmeta.DBMeta; //导入依赖的package包/类
/**
 * Initialize condition-bean meta data.
 */
public void initializeConditionBeanMetaData() {
    final Map<String, DBMeta> dbmetaMap = DBMetaInstanceHandler.getUnmodifiableDBMetaMap();
    final Collection<DBMeta> dbmetas = dbmetaMap.values();
    long before = 0;
    if (_log.isInfoEnabled()) {
        before = System.currentTimeMillis();
        _log.info("...Initializing condition-bean meta data");
    }
    int count = 0;
    for (DBMeta dbmeta : dbmetas) {
        try {
            final BehaviorReadable bhv = byName(dbmeta.getTableDbName());
            bhv.warmUpCommand();
            ++count;
        } catch (IllegalBehaviorStateException ignored) { // means the behavior is suppressed
            if (_log.isDebugEnabled()) {
                _log.debug("No behavior for " + dbmeta.getTableDbName());
            }
        }
    }
    if (_log.isInfoEnabled()) {
        long after = System.currentTimeMillis();
        _log.info("CB initialized: " + count + " [" + DfTraceViewUtil.convertToPerformanceView(after - before) + "]");
    }
}
 
开发者ID:lastaflute,项目名称:lastaflute-example-harbor,代码行数:29,代码来源:ImplementedBehaviorSelector.java

示例3: getBehaviorType

import org.dbflute.dbmeta.DBMeta; //导入依赖的package包/类
/**
 * Get behavior-type by DB meta.
 * @param dbmeta The instance of DB meta for the behavior. (NotNull)
 * @return The type of behavior (as readable type). (NotNull)
 * @throws org.dbflute.exception.IllegalBehaviorStateException When the behavior class is suppressed.
 */
@SuppressWarnings("unchecked")
protected Class<BehaviorReadable> getBehaviorType(DBMeta dbmeta) {
    final String behaviorTypeName = dbmeta.getBehaviorTypeName();
    if (behaviorTypeName == null) {
        String msg = "The dbmeta.getBehaviorTypeName() should not return null: dbmeta=" + dbmeta;
        throw new IllegalStateException(msg);
    }
    final Class<BehaviorReadable> behaviorType;
    try {
        behaviorType = (Class<BehaviorReadable>) Class.forName(behaviorTypeName);
    } catch (ClassNotFoundException e) {
        throw new IllegalBehaviorStateException("The class does not exist: " + behaviorTypeName, e);
    }
    return behaviorType;
}
 
开发者ID:lastaflute,项目名称:lastaflute-example-harbor,代码行数:22,代码来源:ImplementedBehaviorSelector.java

示例4: getCachedDBMeta

import org.dbflute.dbmeta.DBMeta; //导入依赖的package包/类
protected static DBMeta getCachedDBMeta(String tableDbName) { // lazy-load (thank you koyak!)
    DBMeta dbmeta = _tableDbNameInstanceMap.get(tableDbName);
    if (dbmeta != null) {
        return dbmeta;
    }
    synchronized (_tableDbNameInstanceMap) {
        dbmeta = _tableDbNameInstanceMap.get(tableDbName);
        if (dbmeta != null) {
            // an other thread might have initialized
            // or reading might failed by same-time writing
            return dbmeta;
        }
        String dbmetaName = _tableDbNameClassNameMap.get(tableDbName);
        if (dbmetaName == null) {
            return null;
        }
        _tableDbNameInstanceMap.put(tableDbName, toDBMetaInstance(dbmetaName));
        return _tableDbNameInstanceMap.get(tableDbName);
    }
}
 
开发者ID:lastaflute,项目名称:lastaflute-example-harbor,代码行数:21,代码来源:DBMetaInstanceHandler.java

示例5: registerTsv

import org.dbflute.dbmeta.DBMeta; //导入依赖的package包/类
protected void registerTsv(BehaviorSelector selector, Class<? extends BehaviorWritable> bhvType, String tsvName) {
    final String tsvPath = TSV_BASE_PATH + "/" + tsvName;
    final InputStream ins = DfResourceUtil.getResourceStream(tsvPath);
    if (ins == null) {
        throw new IllegalStateException("Not found the TSV: " + tsvPath);
    }
    try {
        logger.debug("...Registering TSV: {}", tsvName);
        final BehaviorWritable writableBhv = selector.select(bhvType);
        final DBMeta dbmeta = writableBhv.asDBMeta();
        final List<Entity> entityList = new ArrayList<Entity>();
        new FileToken().tokenize(ins, resource -> {
            final Map<String, String> columnValueMap = resource.toColumnValueMap();
            final Entity entity = dbmeta.newEntity();
            dbmeta.acceptAllColumnMap(entity, columnValueMap);
            entityList.add(entity);
        }, op -> op.delimitateByTab().encodeAsUTF8().handleEmptyAsNull());
        writableBhv.lumpCreate(entityList, null);
    } catch (IOException e) {
        throw new IllegalStateException("Failed to register the TSV: " + tsvName, e);
    }
}
 
开发者ID:dbflute,项目名称:dbflute-intro,代码行数:23,代码来源:IntroDBInitializer.java

示例6: getValue

import org.dbflute.dbmeta.DBMeta; //导入依赖的package包/类
private ConditionValue getValue(ConditionQuery cq, String column) {
    DBMeta meta = MatcherHelper.getDBMeta(cq);
    String columnPropName = meta.findColumnInfo(column).getPropertyName();

    DfBeanDesc beanDesc = DfBeanDescFactory.getBeanDesc(cq.getClass());
    return (ConditionValue) beanDesc.getPropertyDesc(columnPropName).getValue(cq);
}
 
开发者ID:taktos,项目名称:dbflute-hamcrest,代码行数:8,代码来源:HasCondition.java

示例7: getCQ

import org.dbflute.dbmeta.DBMeta; //导入依赖的package包/类
/**
 * Gets ConditionQuery for related table {@code table}.
 * @param cq the instance of ConditionQuery
 * @param tables names of relation tables
 * @return query for {@code table}
 * @throws DfBeanPropertyNotFoundException no getter method for {@code table}
 */
protected ConditionQuery getCQ(ConditionQuery cq, String[] tables) {
    DBMeta meta = MatcherHelper.getDBMeta(cq);
    String foreignPropertyName = meta.findForeignInfo(tables[0]).getForeignPropertyName();
    DfBeanDesc beanDesc = DfBeanDescFactory.getBeanDesc(cq.getClass());
    ConditionQuery nested = (ConditionQuery) beanDesc.getPropertyDesc("conditionQuery" + foreignPropertyName).getValue(cq);
    if (tables.length == 1) {
        return nested;
    }
    return getCQ(nested, Arrays.copyOfRange(tables, 1, tables.length));
}
 
开发者ID:taktos,项目名称:dbflute-hamcrest,代码行数:18,代码来源:HasRelation.java

示例8: resolveForeignTableName

import org.dbflute.dbmeta.DBMeta; //导入依赖的package包/类
private String resolveForeignTableName(DBMeta meta, String[] foreignTree) {
    ForeignInfo foreignInfo = findForeignInfo(meta, foreignTree[0]);
    if (foreignTree.length == 2) {
        return foreignInfo.getForeignPropertyName();
    }
    return resolveForeignTableName(foreignInfo.getForeignDBMeta(), Arrays.copyOfRange(foreignTree, 1, foreignTree.length));
}
 
开发者ID:taktos,项目名称:dbflute-hamcrest,代码行数:8,代码来源:ShouldSelect.java

示例9: findForeignInfo

import org.dbflute.dbmeta.DBMeta; //导入依赖的package包/类
private ForeignInfo findForeignInfo(DBMeta meta, String foreignTable) {
    try {
        return meta.findForeignInfo(foreignTable);
    } catch (DBMetaNotFoundException e) {
        try {
            return meta.findForeignInfo(foreignTable + "AsOne");
        } catch (DBMetaNotFoundException ne) {
            throw new IllegalArgumentException("Table '" + foreignTable + "' does not exist");
        }
    }
}
 
开发者ID:taktos,项目名称:dbflute-hamcrest,代码行数:12,代码来源:ShouldSelect.java

示例10: prepareEntityResultMap

import org.dbflute.dbmeta.DBMeta; //导入依赖的package包/类
protected Map<String, Object> prepareEntityResultMap(Entity entity) {
    final Map<String, Object> resultMap;
    final DBMeta dbmeta = entity.asDBMeta();
    if (dbmeta.hasPrimaryKey() && entity.hasPrimaryKeyValue()) { // mainly here
        resultMap = dbmeta.extractPrimaryKeyMap(entity);
    } else { // no PK table
        resultMap = prepareHashResultMap(entity.instanceHash());
    }
    return resultMap;
}
 
开发者ID:lastaflute,项目名称:lastaflute,代码行数:11,代码来源:TransactionSavedRecentResult.java

示例11: getUnmodifiableDBMetaMap

import org.dbflute.dbmeta.DBMeta; //导入依赖的package包/类
/**
 * Get the unmodifiable map of DB meta. map:{tableDbName = DBMeta}
 * @return The unmodifiable map that contains all instances of DB meta. (NotNull, NotEmpty)
 */
public static Map<String, DBMeta> getUnmodifiableDBMetaMap() {
    initializeDBMetaMap();
    synchronized (_tableDbNameInstanceMap) {
        return Collections.unmodifiableMap(_tableDbNameInstanceMap);
    }
}
 
开发者ID:lastaflute,项目名称:lastaflute-example-harbor,代码行数:11,代码来源:DBMetaInstanceHandler.java

示例12: findDBMeta

import org.dbflute.dbmeta.DBMeta; //导入依赖的package包/类
/**
 * Find DB meta by table flexible name. (accept quoted name and schema prefix)
 * @param tableFlexibleName The flexible name of table. (NotNull)
 * @return The instance of DB meta. (NotNull)
 * @throws org.dbflute.exception.DBMetaNotFoundException When the DB meta is not found.
 */
public static DBMeta findDBMeta(String tableFlexibleName) {
    DBMeta dbmeta = byTableFlexibleName(tableFlexibleName);
    if (dbmeta == null) {
        String msg = "The DB meta was not found by the table flexible name: key=" + tableFlexibleName;
        throw new DBMetaNotFoundException(msg);
    }
    return dbmeta;
}
 
开发者ID:lastaflute,项目名称:lastaflute-example-harbor,代码行数:15,代码来源:DBMetaInstanceHandler.java

示例13: byTableFlexibleName

import org.dbflute.dbmeta.DBMeta; //导入依赖的package包/类
/**
 * @param tableFlexibleName The flexible name of table. (NotNull)
 * @return The instance of DB meta. (NullAllowed: If the DB meta is not found, it returns null)
 */
protected static DBMeta byTableFlexibleName(String tableFlexibleName) {
    assertStringNotNullAndNotTrimmedEmpty("tableFlexibleName", tableFlexibleName);
    String tableDbName = _tableDbNameFlexibleMap.get(tableFlexibleName);
    if (tableDbName == null) {
        tableDbName = retryByNormalizedName(tableFlexibleName);
    }
    return tableDbName != null ? byTableDbName(tableDbName) : null;
}
 
开发者ID:lastaflute,项目名称:lastaflute-example-harbor,代码行数:13,代码来源:DBMetaInstanceHandler.java

示例14: toDBMetaInstance

import org.dbflute.dbmeta.DBMeta; //导入依赖的package包/类
protected static DBMeta toDBMetaInstance(String dbmetaName) {
    try {
        Class<?> dbmetaType = Class.forName(dbmetaName);
        Method method = dbmetaType.getMethod("getInstance", (Class[])null);
        Object result = method.invoke(null, (Object[])null);
        return (DBMeta)result;
    } catch (Exception e) {
        String msg = "Failed to get the instance: " + dbmetaName;
        throw new IllegalStateException(msg, e);
    }
}
 
开发者ID:lastaflute,项目名称:lastaflute-example-harbor,代码行数:12,代码来源:DBMetaInstanceHandler.java


注:本文中的org.dbflute.dbmeta.DBMeta类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。