Search in sources :

Example 6 with TableMeta

use of com.jfinal.plugin.activerecord.generator.TableMeta in project jboot by yangfuhai.

the class CodeGenHelpler method createMetaBuilder.

public static MetaBuilder createMetaBuilder(DataSource dataSource, String type, boolean removeNoPrimaryKeyTable) {
    MetaBuilder metaBuilder = removeNoPrimaryKeyTable ? new MetaBuilder(dataSource) : new MetaBuilder(dataSource) {

        @Override
        protected void removeNoPrimaryKeyTable(List<TableMeta> ret) {
        // do Nothing...
        }
    };
    metaBuilder.setGenerateRemarks(true);
    switch(type) {
        case DataSourceConfig.TYPE_MYSQL:
            metaBuilder.setDialect(new MysqlDialect());
            break;
        case DataSourceConfig.TYPE_ORACLE:
            metaBuilder.setDialect(new OracleDialect());
            break;
        case DataSourceConfig.TYPE_SQLSERVER:
            metaBuilder.setDialect(new SqlServerDialect());
            break;
        case DataSourceConfig.TYPE_SQLITE:
            metaBuilder.setDialect(new Sqlite3Dialect());
            break;
        case DataSourceConfig.TYPE_ANSISQL:
            metaBuilder.setDialect(new AnsiSqlDialect());
            break;
        case DataSourceConfig.TYPE_POSTGRESQL:
            metaBuilder.setDialect(new PostgreSqlDialect());
            break;
        default:
            throw new JbootIllegalConfigException("only support datasource type : mysql、orcale、sqlserver、sqlite、ansisql and postgresql, please check your jboot.properties. ");
    }
    return metaBuilder;
}
Also used : MetaBuilder(com.jfinal.plugin.activerecord.generator.MetaBuilder) JbootIllegalConfigException(io.jboot.exception.JbootIllegalConfigException) TableMeta(com.jfinal.plugin.activerecord.generator.TableMeta)

Aggregations

TableMeta (com.jfinal.plugin.activerecord.generator.TableMeta)6 MetaBuilder (com.jfinal.plugin.activerecord.generator.MetaBuilder)3 JSONObject (com.alibaba.fastjson.JSONObject)2 StrKit (com.jfinal.kit.StrKit)2 ColumnMeta (com.jfinal.plugin.activerecord.generator.ColumnMeta)2 Engine (com.jfinal.template.Engine)2 ClassPathSourceFactory (com.jfinal.template.source.ClassPathSourceFactory)2 File (java.io.File)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 JbootIllegalConfigException (io.jboot.exception.JbootIllegalConfigException)1 ArrayList (java.util.ArrayList)1