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


Java DbKit类代码示例

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


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

示例1: batchSave

import com.jfinal.plugin.activerecord.DbKit; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
public static int[] batchSave(List<? extends Model> data, int batchSize) {
	Model model = data.get(0);
	Map<String, Object> attrs = (Map<String, Object>) ReflectionUtils.getFieldValue(model, "attrs");
	Class<? extends Model> modelClass = model.getClass();
	Table table = TableMapping.me().getTable(modelClass);
	StringBuilder sql = new StringBuilder();
	List<Object> paras = new ArrayList<Object>();
	DbKit.getConfig().getDialect().forModelSave(table, attrs, sql, paras);
	Object[][] batchPara = new Object[data.size()][attrs.size()];
	for (int i = 0; i < data.size(); i++) {
		int j = 0;
		for (String key : attrs.keySet()) {
			batchPara[i][j++] = data.get(i).get(key);
		}
	}
	return Db.batch(sql.toString(), batchPara, batchSize);
}
 
开发者ID:jflyfox,项目名称:jflyfox_jfinal,代码行数:19,代码来源:ModelKit.java

示例2: batchSave

import com.jfinal.plugin.activerecord.DbKit; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
public static int[] batchSave(List<? extends Model> data, int batchSize) {
    Model model = data.get(0);
    Map<String, Object> attrs = Reflect.on(model).field("attrs").get();
    Class<? extends Model> modelClass = model.getClass();
    Table tableInfo = TableMapping.me().getTable(modelClass);
    StringBuilder sql = new StringBuilder();
    List<Object> paras = Lists.newArrayList();
    DbKit.getConfig().getDialect().forModelSave(tableInfo, attrs, sql, paras);
    Object[][] batchPara = new Object[data.size()][attrs.size()];
    for (int i = 0; i < data.size(); i++) {
        int j = 0;
        for (String key : attrs.keySet()) {
            batchPara[i][j++] = data.get(i).get(key);
        }
    }
    return Db.batch(sql.toString(), batchPara, batchSize);
}
 
开发者ID:OpeningO,项目名称:JFinal-ext2,代码行数:19,代码来源:ModelKit.java

示例3: searchByCache

import com.jfinal.plugin.activerecord.DbKit; //导入依赖的package包/类
public List<M> searchByCache(String cacheName, Object key,
		Map<String, Object> maps, String orderBy) {
	// checkTableName();
	ICache cache = DbKit.getCache();
	List<M> result = cache.get(cacheName, key);
	if (result == null) {
		result = search(maps);
		cache.put(cacheName, key, result);
	}
	return result;
}
 
开发者ID:yaokwok,项目名称:loveabc,代码行数:12,代码来源:Model.java

示例4: searchPaginateByCache

import com.jfinal.plugin.activerecord.DbKit; //导入依赖的package包/类
public Page<M> searchPaginateByCache(String cacheName, Object key,
		int pageNumber, int pageSize, Map<String, Object> maps,
		String orderBy) {
	// checkTableName();
	ICache cache = DbKit.getCache();
	Page<M> result = cache.get(cacheName, key);
	if (result == null) {
		result = searchPaginate(pageNumber, pageSize, maps, orderBy);
		cache.put(cacheName, key, result);
	}
	return result;
}
 
开发者ID:yaokwok,项目名称:loveabc,代码行数:13,代码来源:Model.java

示例5: getConfig

import com.jfinal.plugin.activerecord.DbKit; //导入依赖的package包/类
public static Config getConfig() {
    if(config == null) {
        synchronized (JfinalHelper.class) {
            if(config == null) {
                if(StringHelper.isNotEmpty(configName)) {
                    config = DbKit.getConfig(configName);
                }
                if(config == null) {
                    config = DbKit.getConfig();
                }
            }
        }
    }
    return config;
}
 
开发者ID:snakerflow,项目名称:snakerflow,代码行数:16,代码来源:JfinalHelper.java

示例6: AutoTableBindPlugin

import com.jfinal.plugin.activerecord.DbKit; //导入依赖的package包/类
public AutoTableBindPlugin(IDataSourceProvider dataSourceProvider) {
    this(DbKit.MAIN_CONFIG_NAME, dataSourceProvider, SimpleNameStyles.DEFAULT);
}
 
开发者ID:gumutianqi,项目名称:jfinal-plus,代码行数:4,代码来源:AutoTableBindPlugin.java

示例7: start

import com.jfinal.plugin.activerecord.DbKit; //导入依赖的package包/类
@SuppressWarnings({"unchecked", "rawtypes"})
@Override
public boolean start() {
    final Set<Class<? extends Model>> modelClasses = ClassPathScanning.scan(Model.class);
    if (CollectionUtils.isNotEmpty(modelClasses)) {
        TableBind tb;
        String    tableName;

        for (Class modelClass : modelClasses) {
            if (Modifier.isAbstract(modelClass.getModifiers())) {
                Logger.debug("Goja:: Model {} is Abstract! ignore...", modelClass);
                continue;
            }

            tb = (TableBind) modelClass.getAnnotation(TableBind.class);
            final boolean mainMark = StringUtils.equals(DbKit.MAIN_CONFIG_NAME, confiName);
            if (mainMark && tb == null) {
                tableName = name(modelClass.getSimpleName());
                this.addMapping(tableName, modelClass);
            } else {
                if (tb.ignore()) {
                    continue;
                }
                final String[] configNames = tb.configName();

                if (ArrayUtils.contains(configNames, this.confiName)) {
                    tableName = tb.tableName();
                    final String[] pks = tb.pks();
                    if (pks.length == 1) {
                        String pk_name = pks[0];
                        this.addMapping(tableName, pk_name, modelClass);
                    } else if (pks.length > 1) {
                        this.addMapping(tableName, Func.COMMA_JOINER.join(pks), modelClass);
                    } else {
                        this.addMapping(tableName, modelClass);
                    }
                }
            }
        }
        return super.start();
    }
    return false;
}
 
开发者ID:GojaFramework,项目名称:goja,代码行数:44,代码来源:TableBindPlugin.java


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