From 0fdb9788db6bdfee3cdd564deb338b1880b0e61b Mon Sep 17 00:00:00 2001 From: SunZm Date: Mon, 7 Aug 2017 20:07:30 +0800 Subject: [PATCH] update --- .../mybatis/generator/bridge/MybatisGeneratorBridge.java | 6 ++++++ src/main/java/com/zzg/mybatis/generator/util/DbUtil.java | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/zzg/mybatis/generator/bridge/MybatisGeneratorBridge.java b/src/main/java/com/zzg/mybatis/generator/bridge/MybatisGeneratorBridge.java index 263db5c8..91150175 100644 --- a/src/main/java/com/zzg/mybatis/generator/bridge/MybatisGeneratorBridge.java +++ b/src/main/java/com/zzg/mybatis/generator/bridge/MybatisGeneratorBridge.java @@ -69,6 +69,12 @@ public void generate() throws Exception { TableConfiguration tableConfig = new TableConfiguration(context); tableConfig.setTableName(generatorConfig.getTableName()); tableConfig.setDomainObjectName(generatorConfig.getDomainObjectName()); + + // 针对 postgresql 单独配置 + if (DbType.valueOf(selectedDatabaseConfig.getDbType()).getDriverClass() == "org.postgresql.Driver") { + tableConfig.setDelimitIdentifiers(true); + } + //添加GeneratedKey主键生成 if (StringUtils.isNoneEmpty(generatorConfig.getGenerateKeys())) { tableConfig.setGeneratedKey(new GeneratedKey(generatorConfig.getGenerateKeys(), selectedDatabaseConfig.getDbType(), true, null)); diff --git a/src/main/java/com/zzg/mybatis/generator/util/DbUtil.java b/src/main/java/com/zzg/mybatis/generator/util/DbUtil.java index b1254a3b..3cb18852 100644 --- a/src/main/java/com/zzg/mybatis/generator/util/DbUtil.java +++ b/src/main/java/com/zzg/mybatis/generator/util/DbUtil.java @@ -67,7 +67,8 @@ public static List getTableNames(DatabaseConfig config) throws Exception } else if (DbType.valueOf(config.getDbType()) == DbType.Oracle){ rs = md.getTables(null, config.getUsername().toUpperCase(), null, new String[] {"TABLE", "VIEW"}); } else { - rs = md.getTables(null, config.getUsername().toUpperCase(), null, null); + // rs = md.getTables(null, config.getUsername().toUpperCase(), null, null); + rs = md.getTables(null, "%", "%", new String[] {"TABLE", "VIEW"}); //针对 postgresql 的左侧数据表显示 } while (rs.next()) { tables.add(rs.getString(3));