2019-03-25 10:14
@jfinal
自己试着实现了下,做出来了,效果非常非常好,只是jfinal需要小改几处源码,也不知道改的合不合适:
1、com.jfinal.plugin.activerecord.Table类中的setColumnTypeMap方法需要改成public修饰;
2、com.jfinal.plugin.activerecord.DbKit类中的addModelToConfigMapping方法需要改成public修饰;
3、com.jfinal.plugin.activerecord.ActiveRecordPlugin类中的start方法注释掉第228行
//new TableBuilder().build(tableList, config);
4、自定义MappingKit模板,加入相关逻辑
package #(mappingKitPackageName);
import cn.zcltd.c.ant.dao.*;
import com.jfinal.plugin.activerecord.*;
import java.util.HashMap;
import java.util.Map;
/**
* Generated by JFinal, do not modify this file.
*
* Example:
* public void configPlugin(Plugins me) {
* ActiveRecordPlugin arp = new ActiveRecordPlugin(...);
* #(mappingKitClassName).mapping(arp);
* me.add(arp);
* }
*
2019-03-22 16:05
@123456798 undertow.txt中undertow.devMode=false,或者删掉这个配置,默认就是false
2019-03-15 14:39
@jfinal
该问题已解决,最终问题为dbMeta.getColumns方法拿到的结果,在oracle下ResultSet读取时,若通过rs.getXXX("key")的方式取值,原则上需要跟返回结果的字段先后顺序一致,当field1在field2之前,而取值时已经读取了field2,再读取field1时,就会出错。但经测试,该原则并不稳定,部分字段的前后顺序不会引发问题,部分前后顺序会引发问题,具体场景还需进一步研究或查阅相关文档。以下为jdk8的顺序:
TABLE_CAT
TABLE_SCHEM
TABLE_NAME
1 COLUMN_NAME
DATA_TYPE
2 TYPE_NAME
3 COLUMN_SIZE
BUFFER_LENGTH
4 DECIMAL_DIGITS
7 REMARKS
6 COLUMN_DEF
SQL_DATA_TYPE
SQL_DATETIME_SUB
CHAR_OCTET_LENGTH
ORDINAL_POSITION
5 IS_NULLABLE
SCOPE_CATALOG
SCOPE_SCHEMA
SCOPE_TABLE
SOURCE_DATA_TYPE
IS_AUTOINCREMENT
IS_GENERATEDCOLUMN
标了数字的为jfinal在生成字典时的读取顺序,更改为正确的前后顺序后,未继续出现该问题。
2019-03-15 11:23
JfinalContext.init();
DataSource dataSource = DbKit.getConfig().getDataSource();
String basePath = System.getProperty("user.dir") + "/src/main/java/com/axinfu/tyfp_bs";
String basePkg = "com.axinfu.tyfp_bs";
String baseModelPackageName = basePkg + ".model";
String baseModelOutputDir = basePath + "/model";
String modelPackageName = basePkg + ".dao";
String modelOutputDir = basePath + "/dao";
String mappingPackageName = basePkg;
String mappingOutputDir = basePath;
BaseModelGenerator myBaseModelGenerator = new BaseModelGenerator(baseModelPackageName, baseModelOutputDir);
myBaseModelGenerator.setTemplate("gen/model.e");
ModelGenerator modelGenerator = new ModelGenerator(modelPackageName, baseModelPackageName, modelOutputDir);
modelGenerator.setTemplate("gen/dao.e");
MappingKitGenerator mappingKitGenerator = new MappingKitGenerator(mappingPackageName, mappingOutputDir);
mappingKitGenerator.setTemplate("gen/mapping_kit.e");
mappingKitGenerator.setMappingKitClassName("_MappingKit");
Generator gernerator = new Generator(dataSource, myBaseModelGenerator, modelGenerator);
gernerator.setMappingKitGenerator(mappingKitGenerator);
gernerator.setMetaBuilder(new MetaBuilder(dataSource) {
@Override
protected boolean isSkipTable(String tableName) {
return !tableName.startsWith("FNE_");
}
});
gernerator.setDialect(new OracleDialect());
gernerator.setGenerateDaoInModel(true);
gernerator.setGenerateDataDictionary(true);
//gernerator.setRemovedTableNamePrefixes("t_");
gernerator.generate();