Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2006-2020 the original author or authors.
* Copyright 2006-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -64,7 +64,7 @@ private TopLevelClass buildBasicClass() {
topLevelClass.setVisibility(JavaVisibility.PUBLIC);
topLevelClass.setFinal(true);
topLevelClass.addImportedType(new FullyQualifiedJavaType("org.mybatis.dynamic.sql.SqlColumn")); //$NON-NLS-1$
topLevelClass.addImportedType(new FullyQualifiedJavaType("org.mybatis.dynamic.sql.SqlTable")); //$NON-NLS-1$
topLevelClass.addImportedType(new FullyQualifiedJavaType("org.mybatis.dynamic.sql.AliasableSqlTable")); //$NON-NLS-1$
topLevelClass.addImportedType(new FullyQualifiedJavaType("java.sql.JDBCType")); //$NON-NLS-1$
return topLevelClass;
}
Expand All @@ -76,14 +76,16 @@ private InnerClass buildInnerTableClass(TopLevelClass topLevelClass) {
innerClass.setVisibility(JavaVisibility.PUBLIC);
innerClass.setStatic(true);
innerClass.setFinal(true);
innerClass.setSuperClass(new FullyQualifiedJavaType("org.mybatis.dynamic.sql.SqlTable")); //$NON-NLS-1$
innerClass.setSuperClass(new FullyQualifiedJavaType("org.mybatis.dynamic.sql.AliasableSqlTable<" //$NON-NLS-1$
+ fqjt.getShortName() + ">")); //$NON-NLS-1$

Method method = new Method(fqjt.getShortName());
method.setVisibility(JavaVisibility.PUBLIC);
method.setConstructor(true);
method.addBodyLine("super(\"" //$NON-NLS-1$
+ escapeStringForJava(introspectedTable.getFullyQualifiedTableNameAtRuntime())
+ "\");"); //$NON-NLS-1$
+ "\", " + fqjt.getShortName() + "::new" //$NON-NLS-1$ //$NON-NLS-2$
+ ");"); //$NON-NLS-1$
innerClass.addMethod(method);

commentGenerator.addClassAnnotation(innerClass, introspectedTable, topLevelClass.getImportedTypes());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ private KotlinType buildOuterObject(KotlinFile kotlinFile, FullyQualifiedJavaTyp
KotlinType outerObject = KotlinType.newObject(type.getShortNameWithoutTypeArguments())
.build();

kotlinFile.addImport("org.mybatis.dynamic.sql.SqlTable"); //$NON-NLS-1$
kotlinFile.addImport("org.mybatis.dynamic.sql.AliasableSqlTable"); //$NON-NLS-1$
kotlinFile.addImport("org.mybatis.dynamic.sql.util.kotlin.elements.column"); //$NON-NLS-1$
kotlinFile.addImport("java.sql.JDBCType"); //$NON-NLS-1$
kotlinFile.addNamedItem(outerObject);
Expand All @@ -123,9 +123,10 @@ private KotlinType buildInnerClass() {
String domainObjectName = introspectedTable.getFullyQualifiedTable().getDomainObjectName();

return KotlinType.newClass(domainObjectName)
.withSuperType("SqlTable(\"" //$NON-NLS-1$
.withSuperType("AliasableSqlTable<" + domainObjectName +">(\"" //$NON-NLS-1$ //$NON-NLS-2$
+ escapeStringForKotlin(introspectedTable.getFullyQualifiedTableNameAtRuntime())
+ "\")") //$NON-NLS-1$
+ "\", ::" + domainObjectName //$NON-NLS-1$
+ ")") //$NON-NLS-1$
.build();
}

Expand Down
2 changes: 1 addition & 1 deletion core/mybatis-generator-core/src/site/xhtml/index.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ DatabaseMetaData interface, especially the <code>getColumns</code> and
<td>MyBatis3DynamicSQL, MyBatis3Kotlin</td>
<td>1.4.1+</td>
<td>3.4.2+</td>
<td>1.3.0+</td>
<td>1.3.1+</td>
</tr>
</table>

Expand Down
16 changes: 11 additions & 5 deletions core/mybatis-generator-core/src/site/xhtml/whatsNew.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,21 @@
<h1>What's New in MyBatis Generator</h1>
<h2>Version 1.4.1</h2>
<p>This release is primarily focused on updating the runtimes for MyBatis Dynamic SQL ("MyBatis3DynamicSQL" and
"MyBatis3Kotlin"). The generated code is now dependant on MyBatis Dynamic SQL version 1.3.0 or later
"MyBatis3Kotlin"). The generated code is now dependent on MyBatis Dynamic SQL version 1.3.1 or later
and makes use of newer features in that library. See below for details about that change.
See the GitHub page for milestone 1.4.1 for details other other changes in this release:
See the GitHub page for milestone 1.4.1 for details other changes in this release:
<a target="_blank" href="https://github.com/mybatis/generator/issues?q=milestone%3A1.4.1">Milestone 1.4.1</a>.</p>

<h3>Updated MyBatis Dynamic SQL Runtimes</h3>
<p>The MyBatis3DynamicSQL and MyBatis3Kotlin runtimes have been updated to generate code that requires
version 1.3.0 or later of MyBatis Dynamic SQL. This should be a relatively minor change for most <b>Java</b> users
and should simply require updating the MyBatis Dynamic SQL version to 1.3.0 or later.</p>
version 1.3.1 or later of MyBatis Dynamic SQL. This should be a relatively minor change for most <b>Java</b> users
and should simply require updating the MyBatis Dynamic SQL version to 1.3.1 or later.</p>

<p>For both Java and Kotlin users, the new database model classes (a.k.a. the "support" classes) now extend
<code>AliasableSqlTable</code>. This allows you to specify a table alias directly within an instance
of a table class, rather than specifying the alias in a select statement. This can make the code a bit clearer
if you are doing a self join.
</p>

<p>Differences for <b>Kotlin</b> users are more extensive. As a result of the changes detailed below, several plugin
methods related to the generated Kotlin files have changed or been deprecated. If a method has been deprecated,
Expand All @@ -60,7 +66,7 @@ This has the following benefits:</p>

<p><b>This update will require changes in existing code if you regenerate Kotlin code using this updated version.</b></p>

<p>Generated Kotlin data classes no longer have the word "Record" appended to their names. Otherwise they are
<p>Generated Kotlin data classes no longer have the word "Record" appended to their names. Otherwise, they are
the same. Your use of these classes will need to change. In most cases, you can simply remove the word "Record" from the
reference. For example, if you have a table named "Bar", you may see code like this:</p>
<pre>
Expand Down
2 changes: 1 addition & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@
<dependency>
<groupId>org.mybatis.dynamic-sql</groupId>
<artifactId>mybatis-dynamic-sql</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
Expand Down