public class Generator extends Object
Modifier and Type | Field and Description |
---|---|
protected BaseModelGenerator |
baseModelGenerator |
protected DataDictionaryGenerator |
dataDictionaryGenerator |
protected Dialect |
dialect |
protected boolean |
generateDataDictionary |
protected MappingKitGenerator |
mappingKitGenerator |
protected MetaBuilder |
metaBuilder |
protected ModelGenerator |
modelGenerator |
Constructor and Description |
---|
Generator(DataSource dataSource,
BaseModelGenerator baseModelGenerator) |
Generator(DataSource dataSource,
BaseModelGenerator baseModelGenerator,
ModelGenerator modelGenerator)
使用指定 BaseModelGenerator、ModelGenerator 构造 Generator
生成 BaseModel、Model、MappingKit 三类文件,其中 MappingKit 输出目录与包名与 Model相同
|
Generator(DataSource dataSource,
String baseModelPackageName,
String baseModelOutputDir)
构造 Generator,只生成 baseModel
|
Generator(DataSource dataSource,
String baseModelPackageName,
String baseModelOutputDir,
String modelPackageName,
String modelOutputDir)
构造 Generator,生成 BaseModel、Model、MappingKit 三类文件,其中 MappingKit 输出目录与包名与 Model相同
|
Modifier and Type | Method and Description |
---|---|
void |
addExcludedTable(String... excludedTables)
添加不需要处理的数据表
|
void |
generate() |
void |
setBaseModelTemplate(String baseModelTemplate)
设置用于生成 BaseModel 的模板文件,模板引擎将在 class path 与 jar 包内寻找模板文件
默认模板为:"/com/jfinal/plugin/activerecord/generator/base_model_template.jf"
|
void |
setDataDictionaryFileName(String dataDictionaryFileName)
设置数据字典 DataDictionary 文件输出目录,默认值为 "_DataDictionary.txt"
|
void |
setDataDictionaryGenerator(DataDictionaryGenerator dataDictionaryGenerator)
设置 DataDictionaryGenerator,便于扩展自定义 DataDictionaryGenerator
|
void |
setDataDictionaryOutputDir(String dataDictionaryOutputDir)
设置数据字典 DataDictionary 文件输出目录,默认与 modelOutputDir 相同
|
void |
setDialect(Dialect dialect)
设置数据库方言,默认为 MysqlDialect
|
void |
setGenerateChainSetter(boolean generateChainSetter)
设置 BaseModel 是否生成链式 setter 方法
|
void |
setGenerateDaoInModel(boolean generateDaoInModel)
设置是否在 Model 中生成 dao 对象,默认生成
|
void |
setGenerateDataDictionary(boolean generateDataDictionary)
设置是否生成数据字典 Dictionary 文件,默认不生成
|
void |
setMappingKitClassName(String mappingKitClassName)
设置 MappingKit 类名,默认值为: "_MappingKit"
|
void |
setMappingKitGenerator(MappingKitGenerator mappingKitGenerator)
设置 MappingKitGenerator,便于扩展自定义 MappingKitGenerator
|
void |
setMappingKitOutputDir(String mappingKitOutputDir)
设置 MappingKit 文件输出目录,默认与 modelOutputDir 相同,
在设置此变量的同时需要设置 mappingKitPackageName
|
void |
setMappingKitPackageName(String mappingKitPackageName)
设置 MappingKit 文件包名,默认与 modelPackageName 相同,
在设置此变的同时需要设置 mappingKitOutputDir
|
void |
setMappingKitTemplate(String mappingKitTemplate)
设置用于生成 MappingKit 的模板文件,模板引擎将在 class path 与 jar 包内寻找模板文件
默认模板为:"/com/jfinal/plugin/activerecord/generator/mapping_kit_template.jf"
|
void |
setMetaBuilder(MetaBuilder metaBuilder)
设置 MetaBuilder,便于扩展自定义 MetaBuilder
|
void |
setModelTemplate(String modelTemplate)
设置用于生成 Model 的模板文件,模板引擎将在 class path 与 jar 包内寻找模板文件
默认模板为:"/com/jfinal/plugin/activerecord/generator/model_template.jf"
|
void |
setRemovedTableNamePrefixes(String... removedTableNamePrefixes)
设置需要被移除的表名前缀,仅用于生成 modelName 与 baseModelName
例如表名 "osc_account",移除前缀 "osc_" 后变为 "account"
|
void |
setTypeMapping(TypeMapping typeMapping) |
protected Dialect dialect
protected MetaBuilder metaBuilder
protected BaseModelGenerator baseModelGenerator
protected ModelGenerator modelGenerator
protected MappingKitGenerator mappingKitGenerator
protected DataDictionaryGenerator dataDictionaryGenerator
protected boolean generateDataDictionary
public Generator(DataSource dataSource, String baseModelPackageName, String baseModelOutputDir, String modelPackageName, String modelOutputDir)
dataSource
- 数据源baseModelPackageName
- base model 包名baseModelOutputDir
- base mode 输出目录modelPackageName
- model 包名modelOutputDir
- model 输出目录public Generator(DataSource dataSource, String baseModelPackageName, String baseModelOutputDir)
dataSource
- 数据源baseModelPackageName
- base model 包名baseModelOutputDir
- base mode 输出目录public Generator(DataSource dataSource, BaseModelGenerator baseModelGenerator)
public Generator(DataSource dataSource, BaseModelGenerator baseModelGenerator, ModelGenerator modelGenerator)
public void setMetaBuilder(MetaBuilder metaBuilder)
public void setTypeMapping(TypeMapping typeMapping)
public void setMappingKitGenerator(MappingKitGenerator mappingKitGenerator)
public void setDataDictionaryGenerator(DataDictionaryGenerator dataDictionaryGenerator)
public void setDialect(Dialect dialect)
public void setBaseModelTemplate(String baseModelTemplate)
public void setGenerateChainSetter(boolean generateChainSetter)
public void setRemovedTableNamePrefixes(String... removedTableNamePrefixes)
public void addExcludedTable(String... excludedTables)
public void setModelTemplate(String modelTemplate)
public void setGenerateDaoInModel(boolean generateDaoInModel)
public void setGenerateDataDictionary(boolean generateDataDictionary)
public void setMappingKitTemplate(String mappingKitTemplate)
public void setMappingKitOutputDir(String mappingKitOutputDir)
public void setMappingKitPackageName(String mappingKitPackageName)
public void setMappingKitClassName(String mappingKitClassName)
public void setDataDictionaryOutputDir(String dataDictionaryOutputDir)
public void setDataDictionaryFileName(String dataDictionaryFileName)
public void generate()
Copyright © 2018. All rights reserved.