Compare commits

...
6 Commits
5 changed files with 23 additions and 6 deletions
+3 -1
View File
@@ -27,7 +27,7 @@ Maven引用:
<dependency>
<groupId>com.itfsw</groupId>
<artifactId>mybatis-generator-plugin</artifactId>
<version>1.1.1</version>
<version>1.1.2</version>
</dependency>
```
---------------------------------------
@@ -698,6 +698,8 @@ Mybatis Generator是原生支持自定义注释的(commentGenerator配置type
>warning: 模板引擎采用的是freemarker所以一些freemarker指令参数(如:<#if xx></#if>、${.now?string("yyyy-MM-dd HH:mm:ss")})都是可以使用的,请自己尝试。
>warning: [默认模板](https://github.com/itfsw/mybatis-generator-plugin/blob/master/src/main/resources/default-comment.ftl)
| 注释ID | 传入参数 | 备注 |
| ----- | ----- | ---- |
| addJavaFileComment | mgb<br>[compilationUnit](https://github.com/mybatis/generator/blob/master/core/mybatis-generator-core/src/main/java/org/mybatis/generator/api/dom/java/CompilationUnit.java) | Java文件注释 |
+2 -2
View File
@@ -3,7 +3,7 @@
<groupId>com.itfsw</groupId>
<artifactId>mybatis-generator-plugin</artifactId>
<version>1.1.1</version>
<version>1.1.3-SNAPSHOT</version>
<packaging>jar</packaging>
<name>${project.groupId}:${project.artifactId}</name>
@@ -212,7 +212,7 @@
<connection>scm:git:https://github.com/itfsw/mybatis-generator-plugin.git</connection>
<developerConnection>scm:git:https://github.com/itfsw/mybatis-generator-plugin.git</developerConnection>
<url>https://github.com/itfsw/mybatis-generator-plugin</url>
<tag>V1.1.1</tag>
<tag>HEAD</tag>
</scm>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++distribution++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
@@ -189,6 +189,13 @@ public class SelectSelectivePlugin extends BasePlugin {
if (stringHasValue(introspectedTable.getSelectByExampleQueryId())) {
selectByExampleSelectiveEle.addElement(new TextElement("'" + introspectedTable.getSelectByExampleQueryId() + "' as QUERYID,"));
}
// issues#20
XmlElement ifDistinctElement = new XmlElement("if");
ifDistinctElement.addAttribute(new Attribute("test", "example.distinct"));
ifDistinctElement.addElement(new TextElement("distinct"));
selectByExampleSelectiveEle.addElement(ifDistinctElement);
selectByExampleSelectiveEle.addElement(columnsEle);
selectByExampleSelectiveEle.addElement(new TextElement("from " + introspectedTable.getAliasedFullyQualifiedTableNameAtRuntime()));
@@ -79,7 +79,7 @@ public class SelectSelectivePluginTest {
// 2. 执行sql
List list = (List) tbMapper.invoke("selectByExampleSelective", tbExample.getObject(), columns1);
Assert.assertEquals(list.size(), 3);
Assert.assertEquals(list.size(), 4);
int index = 0;
for (Object obj : list) {
if (index == 1) {
@@ -99,6 +99,13 @@ public class SelectSelectivePluginTest {
index++;
}
// 3. 测试 distinct
tbExample.invoke("setDistinct", true);
String sql1 = SqlHelper.getFormatMapperSql(tbMapper.getObject(), "selectByExampleSelective", tbExample.getObject(), columns1);
Assert.assertEquals(sql1, "select distinct field1 from tb WHERE ( id < '100' ) order by field2 asc");
List list1 = (List) tbMapper.invoke("selectByExampleSelective", tbExample.getObject(), columns1);
Assert.assertEquals(list1.size(), 3);
}
});
}
@@ -228,7 +235,7 @@ public class SelectSelectivePluginTest {
// 2. 执行sql
List list = (List) tbMapper.invoke("selectByExampleSelective", tbExample.getObject(), columns1);
Assert.assertEquals(list.size(), 3);
Assert.assertEquals(list.size(), 4);
int index = 0;
for (Object obj : list) {
if (index == 0) {
@@ -282,7 +289,7 @@ public class SelectSelectivePluginTest {
// 2. 执行sql
List list = (List) tbMapper.invoke("selectByExampleSelective", tbExample.getObject(), columns1);
Assert.assertEquals(list.size(), 3);
Assert.assertEquals(list.size(), 4);
int index = 0;
for (Object obj : list) {
if (index == 0) {
@@ -32,6 +32,7 @@ CREATE TABLE `tb` (
INSERT INTO `tb` VALUES ('1', 'fd1', null);
INSERT INTO `tb` VALUES ('2', null, '2');
INSERT INTO `tb` VALUES ('3', 'fd3', '3');
INSERT INTO `tb` VALUES ('4', 'fd3', '4');
-- ----------------------------
-- Table structure for tb_blobs