Skip to content

Commit

Permalink
升级mybatis-generator-core版本
Browse files Browse the repository at this point in the history
  • Loading branch information
zouzhigang committed Mar 22, 2018
1 parent 184e709 commit 6ebbbcb
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<version>1.3.5</version>
<version>1.3.6</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ public void generate() throws Exception {
tableConfig.setSelectByExampleStatementEnabled(false);
}

tableConfig.setSchema(selectedDatabaseConfig.getSchema());
if (DbType.MySQL.name().equals(selectedDatabaseConfig.getDbType())) {
tableConfig.setSchema(selectedDatabaseConfig.getSchema());
} else {
tableConfig.setCatalog(selectedDatabaseConfig.getSchema());
}

// 针对 postgresql 单独配置
if (DbType.valueOf(selectedDatabaseConfig.getDbType()).getDriverClass() == "org.postgresql.Driver") {
Expand Down Expand Up @@ -100,6 +104,10 @@ public void generate() throws Exception {
tableConfig.addProperty("useActualColumnNames", "true");
}
JDBCConnectionConfiguration jdbcConfig = new JDBCConnectionConfiguration();
// http://www.mybatis.org/generator/usage/mysql.html
if (DbType.MySQL.name().equals(selectedDatabaseConfig.getDbType())) {
jdbcConfig.addProperty("nullCatalogMeansCurrent", "true");
}
jdbcConfig.setDriverClass(DbType.valueOf(selectedDatabaseConfig.getDbType()).getDriverClass());
jdbcConfig.setConnectionURL(DbUtil.getConnectionUrlWithSchema(selectedDatabaseConfig));
jdbcConfig.setUserId(selectedDatabaseConfig.getUsername());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.mybatis.generator.internal.util.StringUtility;

import java.util.Properties;
import java.util.Set;

import static org.mybatis.generator.internal.util.StringUtility.isTrue;

Expand Down Expand Up @@ -69,7 +70,33 @@ public void addRootComment(XmlElement rootElement) {
return;
}

public void addConfigurationProperties(Properties properties) {
@Override
public void addGeneralMethodAnnotation(Method method, IntrospectedTable introspectedTable, Set<FullyQualifiedJavaType> set) {


}

@Override
public void addGeneralMethodAnnotation(Method method, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn, Set<FullyQualifiedJavaType> set) {

}

@Override
public void addFieldAnnotation(Field field, IntrospectedTable introspectedTable, Set<FullyQualifiedJavaType> set) {

}

@Override
public void addFieldAnnotation(Field field, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn, Set<FullyQualifiedJavaType> set) {

}

@Override
public void addClassAnnotation(InnerClass innerClass, IntrospectedTable introspectedTable, Set<FullyQualifiedJavaType> set) {

}

public void addConfigurationProperties(Properties properties) {
this.properties.putAll(properties);
columnRemarks = isTrue(properties
.getProperty("columnRemarks"));
Expand All @@ -84,6 +111,7 @@ public void addClassComment(InnerClass innerClass,
public void addModelClassComment(TopLevelClass topLevelClass,
IntrospectedTable introspectedTable) {
topLevelClass.addJavaDocLine("/**");
topLevelClass.addJavaDocLine(" * " + introspectedTable.getFullyQualifiedTable().getIntrospectedTableName());
topLevelClass.addJavaDocLine(" * @author ");
topLevelClass.addJavaDocLine(" */");
if(isAnnotations) {
Expand Down

0 comments on commit 6ebbbcb

Please sign in to comment.