Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mybatis-generator-plugin
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
mybatis-generator-plugin
Commits
8e56ee0d
Commit
8e56ee0d
authored
Jul 31, 2017
by
hewei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SelectiveEnhancedPlugin 测试用例
parent
91077c19
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
455 additions
and
1 deletion
+455
-1
src/test/java/com/itfsw/mybatis/generator/plugins/SelectiveEnhancedPluginTest.java
...ybatis/generator/plugins/SelectiveEnhancedPluginTest.java
+261
-0
src/test/resources/db.properties
src/test/resources/db.properties
+1
-1
src/test/resources/scripts/SelectiveEnhancedPlugin/init.sql
src/test/resources/scripts/SelectiveEnhancedPlugin/init.sql
+37
-0
src/test/resources/scripts/SelectiveEnhancedPlugin/mybatis-generator-with-UpsertPlugin-with-wrong-place.xml
.../mybatis-generator-with-UpsertPlugin-with-wrong-place.xml
+52
-0
src/test/resources/scripts/SelectiveEnhancedPlugin/mybatis-generator-without-ModelColumnPlugin.xml
...cedPlugin/mybatis-generator-without-ModelColumnPlugin.xml
+50
-0
src/test/resources/scripts/SelectiveEnhancedPlugin/mybatis-generator.xml
...ces/scripts/SelectiveEnhancedPlugin/mybatis-generator.xml
+54
-0
No files found.
src/test/java/com/itfsw/mybatis/generator/plugins/SelectiveEnhancedPluginTest.java
0 → 100644
View file @
8e56ee0d
/*
* Copyright (c) 2017.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com
.
itfsw
.
mybatis
.
generator
.
plugins
;
import
com.itfsw.mybatis.generator.plugins.tools.*
;
import
org.apache.ibatis.session.SqlSession
;
import
org.junit.Assert
;
import
org.junit.BeforeClass
;
import
org.junit.Test
;
import
org.mybatis.generator.exception.InvalidConfigurationException
;
import
org.mybatis.generator.exception.XMLParserException
;
import
java.io.IOException
;
import
java.lang.reflect.Array
;
import
java.sql.SQLException
;
/**
* ---------------------------------------------------------------------------
*
* ---------------------------------------------------------------------------
* @author: hewei
* @time:2017/7/28 15:47
* ---------------------------------------------------------------------------
*/
public
class
SelectiveEnhancedPluginTest
{
/**
* 初始化数据库
*/
@BeforeClass
public
static
void
init
()
throws
SQLException
,
IOException
,
ClassNotFoundException
{
DBHelper
.
createDB
(
"scripts/SelectiveEnhancedPlugin/init.sql"
);
}
/**
* 测试配置异常
*/
@Test
public
void
testWarnings
()
throws
IOException
,
XMLParserException
,
InvalidConfigurationException
,
InterruptedException
,
SQLException
{
// 1. 没有配置ModelColumnPlugin插件
MyBatisGeneratorTool
tool
=
MyBatisGeneratorTool
.
create
(
"scripts/SelectiveEnhancedPlugin/mybatis-generator-without-ModelColumnPlugin.xml"
);
tool
.
generate
();
Assert
.
assertEquals
(
tool
.
getWarnings
().
get
(
0
),
"itfsw:插件com.itfsw.mybatis.generator.plugins.SelectiveEnhancedPlugin插件需配合com.itfsw.mybatis.generator.plugins.ModelColumnPlugin插件使用!"
);
// 2. 没有配置UpsertPlugin插件位置配置错误
tool
=
MyBatisGeneratorTool
.
create
(
"scripts/SelectiveEnhancedPlugin/mybatis-generator-with-UpsertPlugin-with-wrong-place.xml"
);
tool
.
generate
();
Assert
.
assertEquals
(
tool
.
getWarnings
().
get
(
0
),
"itfsw:插件com.itfsw.mybatis.generator.plugins.SelectiveEnhancedPlugin插件建议配置在插件com.itfsw.mybatis.generator.plugins.UpsertPlugin后面,否则某些功能可能得不到增强!"
);
}
/**
* 测试Model
*/
@Test
public
void
testModel
()
throws
IOException
,
XMLParserException
,
InvalidConfigurationException
,
InterruptedException
,
SQLException
{
MyBatisGeneratorTool
tool
=
MyBatisGeneratorTool
.
create
(
"scripts/SelectiveEnhancedPlugin/mybatis-generator.xml"
);
tool
.
generate
(
new
AbstractShellCallback
()
{
@Override
public
void
reloadProject
(
SqlSession
sqlSession
,
ClassLoader
loader
,
String
packagz
)
throws
Exception
{
ObjectUtil
tb
=
new
ObjectUtil
(
loader
,
packagz
+
".Tb"
);
ObjectUtil
TbColumnField1
=
new
ObjectUtil
(
loader
,
packagz
+
".Tb$Column#field1"
);
ObjectUtil
TbColumnTsIncF2
=
new
ObjectUtil
(
loader
,
packagz
+
".Tb$Column#tsIncF2"
);
Object
columns
=
Array
.
newInstance
(
TbColumnField1
.
getCls
(),
2
);
Array
.
set
(
columns
,
0
,
TbColumnField1
.
getObject
());
Array
.
set
(
columns
,
1
,
TbColumnTsIncF2
.
getObject
());
tb
.
invoke
(
"selective"
,
columns
);
Assert
.
assertTrue
((
Boolean
)
tb
.
invoke
(
"isSelective"
));
Assert
.
assertTrue
((
Boolean
)
tb
.
invoke
(
"isSelective"
,
"field_1"
));
Assert
.
assertFalse
((
Boolean
)
tb
.
invoke
(
"isSelective"
,
"inc_f1"
));
Assert
.
assertTrue
((
Boolean
)
tb
.
invoke
(
"isSelective"
,
"inc_f2"
));
}
});
}
/**
* 测试insertSelective增强
*/
@Test
public
void
testInsertSelective
()
throws
IOException
,
XMLParserException
,
InvalidConfigurationException
,
InterruptedException
,
SQLException
{
MyBatisGeneratorTool
tool
=
MyBatisGeneratorTool
.
create
(
"scripts/SelectiveEnhancedPlugin/mybatis-generator.xml"
);
tool
.
generate
(
new
AbstractShellCallback
()
{
@Override
public
void
reloadProject
(
SqlSession
sqlSession
,
ClassLoader
loader
,
String
packagz
)
throws
Exception
{
ObjectUtil
tbMapper
=
new
ObjectUtil
(
sqlSession
.
getMapper
(
loader
.
loadClass
(
packagz
+
".TbMapper"
)));
ObjectUtil
tb
=
new
ObjectUtil
(
loader
,
packagz
+
".Tb"
);
tb
.
set
(
"incF3"
,
10
l
);
tb
.
set
(
"tsIncF2"
,
5
l
);
// selective
ObjectUtil
TbColumnField1
=
new
ObjectUtil
(
loader
,
packagz
+
".Tb$Column#field1"
);
ObjectUtil
TbColumnTsIncF2
=
new
ObjectUtil
(
loader
,
packagz
+
".Tb$Column#tsIncF2"
);
Object
columns
=
Array
.
newInstance
(
TbColumnField1
.
getCls
(),
2
);
Array
.
set
(
columns
,
0
,
TbColumnField1
.
getObject
());
Array
.
set
(
columns
,
1
,
TbColumnTsIncF2
.
getObject
());
tb
.
invoke
(
"selective"
,
columns
);
// sql
String
sql
=
SqlHelper
.
getFormatMapperSql
(
tbMapper
.
getObject
(),
"insertSelective"
,
tb
.
getObject
());
Assert
.
assertEquals
(
sql
,
"insert into tb ( field_1, inc_f2 ) values ( 'null', 5 )"
);
Object
result
=
tbMapper
.
invoke
(
"insertSelective"
,
tb
.
getObject
());
Assert
.
assertEquals
(
result
,
1
);
}
});
}
/**
* 测试 updateByExampleSelective
*/
@Test
public
void
testUpdateByExampleSelective
()
throws
IOException
,
XMLParserException
,
InvalidConfigurationException
,
InterruptedException
,
SQLException
{
MyBatisGeneratorTool
tool
=
MyBatisGeneratorTool
.
create
(
"scripts/SelectiveEnhancedPlugin/mybatis-generator.xml"
);
tool
.
generate
(
new
AbstractShellCallback
()
{
@Override
public
void
reloadProject
(
SqlSession
sqlSession
,
ClassLoader
loader
,
String
packagz
)
throws
Exception
{
ObjectUtil
tbMapper
=
new
ObjectUtil
(
sqlSession
.
getMapper
(
loader
.
loadClass
(
packagz
+
".TbMapper"
)));
ObjectUtil
TbExample
=
new
ObjectUtil
(
loader
,
packagz
+
".TbExample"
);
ObjectUtil
criteria
=
new
ObjectUtil
(
TbExample
.
invoke
(
"createCriteria"
));
criteria
.
invoke
(
"andIdEqualTo"
,
1
l
);
ObjectUtil
tb
=
new
ObjectUtil
(
loader
,
packagz
+
".Tb"
);
tb
.
set
(
"incF3"
,
10
l
);
tb
.
set
(
"tsIncF2"
,
5
l
);
// selective
ObjectUtil
TbColumnField1
=
new
ObjectUtil
(
loader
,
packagz
+
".Tb$Column#field1"
);
ObjectUtil
TbColumnTsIncF2
=
new
ObjectUtil
(
loader
,
packagz
+
".Tb$Column#tsIncF2"
);
Object
columns
=
Array
.
newInstance
(
TbColumnField1
.
getCls
(),
2
);
Array
.
set
(
columns
,
0
,
TbColumnField1
.
getObject
());
Array
.
set
(
columns
,
1
,
TbColumnTsIncF2
.
getObject
());
tb
.
invoke
(
"selective"
,
columns
);
// sql
String
sql
=
SqlHelper
.
getFormatMapperSql
(
tbMapper
.
getObject
(),
"updateByExampleSelective"
,
tb
.
getObject
(),
TbExample
.
getObject
());
Assert
.
assertEquals
(
sql
,
"update tb SET field_1 = 'null', inc_f2 = 5 WHERE ( id = '1' )"
);
Object
result
=
tbMapper
.
invoke
(
"updateByExampleSelective"
,
tb
.
getObject
(),
TbExample
.
getObject
());
Assert
.
assertEquals
(
result
,
1
);
}
});
}
/**
* 测试 updateByPrimaryKeySelective
*/
@Test
public
void
testUpdateByPrimaryKeySelective
()
throws
IOException
,
XMLParserException
,
InvalidConfigurationException
,
InterruptedException
,
SQLException
{
MyBatisGeneratorTool
tool
=
MyBatisGeneratorTool
.
create
(
"scripts/SelectiveEnhancedPlugin/mybatis-generator.xml"
);
tool
.
generate
(
new
AbstractShellCallback
()
{
@Override
public
void
reloadProject
(
SqlSession
sqlSession
,
ClassLoader
loader
,
String
packagz
)
throws
Exception
{
ObjectUtil
tbMapper
=
new
ObjectUtil
(
sqlSession
.
getMapper
(
loader
.
loadClass
(
packagz
+
".TbMapper"
)));
ObjectUtil
tb
=
new
ObjectUtil
(
loader
,
packagz
+
".Tb"
);
tb
.
set
(
"id"
,
2
l
);
tb
.
set
(
"incF3"
,
10
l
);
tb
.
set
(
"tsIncF2"
,
5
l
);
// selective
ObjectUtil
TbColumnField1
=
new
ObjectUtil
(
loader
,
packagz
+
".Tb$Column#field1"
);
ObjectUtil
TbColumnTsIncF2
=
new
ObjectUtil
(
loader
,
packagz
+
".Tb$Column#tsIncF2"
);
Object
columns
=
Array
.
newInstance
(
TbColumnField1
.
getCls
(),
2
);
Array
.
set
(
columns
,
0
,
TbColumnField1
.
getObject
());
Array
.
set
(
columns
,
1
,
TbColumnTsIncF2
.
getObject
());
tb
.
invoke
(
"selective"
,
columns
);
// sql
String
sql
=
SqlHelper
.
getFormatMapperSql
(
tbMapper
.
getObject
(),
"updateByPrimaryKeySelective"
,
tb
.
getObject
());
Assert
.
assertEquals
(
sql
,
"update tb SET field_1 = 'null', inc_f2 = 5 where id = 2"
);
Object
result
=
tbMapper
.
invoke
(
"updateByPrimaryKeySelective"
,
tb
.
getObject
());
Assert
.
assertEquals
(
result
,
1
);
}
});
}
/**
* 测试 upsertSelective
*/
@Test
public
void
testUpsertSelective
()
throws
IOException
,
XMLParserException
,
InvalidConfigurationException
,
InterruptedException
,
SQLException
{
MyBatisGeneratorTool
tool
=
MyBatisGeneratorTool
.
create
(
"scripts/SelectiveEnhancedPlugin/mybatis-generator.xml"
);
tool
.
generate
(
new
AbstractShellCallback
()
{
@Override
public
void
reloadProject
(
SqlSession
sqlSession
,
ClassLoader
loader
,
String
packagz
)
throws
Exception
{
ObjectUtil
tbMapper
=
new
ObjectUtil
(
sqlSession
.
getMapper
(
loader
.
loadClass
(
packagz
+
".TbMapper"
)));
ObjectUtil
tb
=
new
ObjectUtil
(
loader
,
packagz
+
".Tb"
);
tb
.
set
(
"id"
,
10
l
);
tb
.
set
(
"incF3"
,
10
l
);
tb
.
set
(
"tsIncF2"
,
5
l
);
// selective
ObjectUtil
TbColumnId
=
new
ObjectUtil
(
loader
,
packagz
+
".Tb$Column#id"
);
ObjectUtil
TbColumnField1
=
new
ObjectUtil
(
loader
,
packagz
+
".Tb$Column#field1"
);
ObjectUtil
TbColumnTsIncF2
=
new
ObjectUtil
(
loader
,
packagz
+
".Tb$Column#tsIncF2"
);
Object
columns
=
Array
.
newInstance
(
TbColumnField1
.
getCls
(),
3
);
Array
.
set
(
columns
,
0
,
TbColumnId
.
getObject
());
Array
.
set
(
columns
,
1
,
TbColumnField1
.
getObject
());
Array
.
set
(
columns
,
2
,
TbColumnTsIncF2
.
getObject
());
tb
.
invoke
(
"selective"
,
columns
);
// sql
String
sql
=
SqlHelper
.
getFormatMapperSql
(
tbMapper
.
getObject
(),
"upsertSelective"
,
tb
.
getObject
());
Assert
.
assertEquals
(
sql
,
"insert into tb ( id, field_1, inc_f2 ) values ( 10, 'null', 5 ) on duplicate key update id = 10, field_1 = 'null', inc_f2 = 5"
);
Object
result
=
tbMapper
.
invoke
(
"upsertSelective"
,
tb
.
getObject
());
Assert
.
assertEquals
(
result
,
1
);
}
});
}
/**
* 测试 upsertByExampleSelective
*/
@Test
public
void
testUpsertByExampleSelective
()
throws
IOException
,
XMLParserException
,
InvalidConfigurationException
,
InterruptedException
,
SQLException
{
MyBatisGeneratorTool
tool
=
MyBatisGeneratorTool
.
create
(
"scripts/SelectiveEnhancedPlugin/mybatis-generator.xml"
);
tool
.
generate
(
new
AbstractShellCallback
()
{
@Override
public
void
reloadProject
(
SqlSession
sqlSession
,
ClassLoader
loader
,
String
packagz
)
throws
Exception
{
ObjectUtil
tbMapper
=
new
ObjectUtil
(
sqlSession
.
getMapper
(
loader
.
loadClass
(
packagz
+
".TbMapper"
)));
ObjectUtil
TbExample
=
new
ObjectUtil
(
loader
,
packagz
+
".TbExample"
);
ObjectUtil
criteria
=
new
ObjectUtil
(
TbExample
.
invoke
(
"createCriteria"
));
criteria
.
invoke
(
"andIdEqualTo"
,
99
l
);
ObjectUtil
tb
=
new
ObjectUtil
(
loader
,
packagz
+
".Tb"
);
tb
.
set
(
"id"
,
99
l
);
tb
.
set
(
"incF3"
,
10
l
);
tb
.
set
(
"tsIncF2"
,
5
l
);
// selective
ObjectUtil
TbColumnId
=
new
ObjectUtil
(
loader
,
packagz
+
".Tb$Column#id"
);
ObjectUtil
TbColumnField1
=
new
ObjectUtil
(
loader
,
packagz
+
".Tb$Column#field1"
);
ObjectUtil
TbColumnTsIncF2
=
new
ObjectUtil
(
loader
,
packagz
+
".Tb$Column#tsIncF2"
);
Object
columns
=
Array
.
newInstance
(
TbColumnField1
.
getCls
(),
3
);
Array
.
set
(
columns
,
0
,
TbColumnId
.
getObject
());
Array
.
set
(
columns
,
1
,
TbColumnField1
.
getObject
());
Array
.
set
(
columns
,
2
,
TbColumnTsIncF2
.
getObject
());
tb
.
invoke
(
"selective"
,
columns
);
// sql
String
sql
=
SqlHelper
.
getFormatMapperSql
(
tbMapper
.
getObject
(),
"upsertByExampleSelective"
,
tb
.
getObject
(),
TbExample
.
getObject
());
Assert
.
assertEquals
(
sql
,
"insert into tb ( id, field_1, inc_f2 ) select 99, 'null', 5 from dual where not exists ( select 1 from tb WHERE ( id = '99' ) ) ; update tb set inc_f2 = 5, inc_f3 = 10 WHERE ( id = '99' )"
);
Object
result
=
tbMapper
.
invoke
(
"upsertByExampleSelective"
,
tb
.
getObject
(),
TbExample
.
getObject
());
Assert
.
assertEquals
(
result
,
1
);
result
=
tbMapper
.
invoke
(
"upsertByExampleSelective"
,
tb
.
getObject
(),
TbExample
.
getObject
());
Assert
.
assertEquals
(
result
,
0
);
}
});
}
}
src/test/resources/db.properties
View file @
8e56ee0d
...
@@ -15,6 +15,6 @@
...
@@ -15,6 +15,6 @@
#
#
driver
=
com.mysql.jdbc.Driver
driver
=
com.mysql.jdbc.Driver
url
=
jdbc:mysql://localhost:3306/mybatis-generator-plugin?characterEncoding=UTF-8&a
mp;a
llowMultiQueries=true
url
=
jdbc:mysql://localhost:3306/mybatis-generator-plugin?characterEncoding=UTF-8&allowMultiQueries=true
username
=
root
username
=
root
password
=
root
password
=
root
\ No newline at end of file
src/test/resources/scripts/SelectiveEnhancedPlugin/init.sql
0 → 100644
View file @
8e56ee0d
/*
Navicat MySQL Data Transfer
Source Server : localhost
Source Server Version : 50617
Source Host : localhost:3306
Source Database : mybatis-generator-plugin
Target Server Type : MYSQL
Target Server Version : 50617
File Encoding : 65001
Date: 2017-07-05 17:21:41
*/
SET
FOREIGN_KEY_CHECKS
=
0
;
-- ----------------------------
-- Table structure for tb
-- ----------------------------
DROP
TABLE
IF
EXISTS
`tb`
;
CREATE
TABLE
`tb`
(
`id`
bigint
(
20
)
NOT
NULL
AUTO_INCREMENT
COMMENT
'注释1'
,
`field_1`
varchar
(
255
)
DEFAULT
NULL
COMMENT
'注释2'
,
`inc_f1`
bigint
(
20
)
NOT
NULL
DEFAULT
'0'
,
`inc_f2`
bigint
(
20
)
NOT
NULL
DEFAULT
'0'
,
`inc_f3`
bigint
(
20
)
NOT
NULL
DEFAULT
'0'
,
PRIMARY
KEY
(
`id`
)
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
5
DEFAULT
CHARSET
=
utf8
;
-- ----------------------------
-- Records of tb
-- ----------------------------
INSERT
INTO
`tb`
VALUES
(
'1'
,
'fd1'
,
'0'
,
'0'
,
'0'
);
INSERT
INTO
`tb`
VALUES
(
'2'
,
'fd2'
,
'1'
,
'2'
,
'3'
);
INSERT
INTO
`tb`
VALUES
(
'3'
,
null
,
'3'
,
'2'
,
'1'
);
INSERT
INTO
`tb`
VALUES
(
'4'
,
'fd3'
,
'1'
,
'1'
,
'1'
);
\ No newline at end of file
src/test/resources/scripts/SelectiveEnhancedPlugin/mybatis-generator-with-UpsertPlugin-with-wrong-place.xml
0 → 100644
View file @
8e56ee0d
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2017.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<!DOCTYPE generatorConfiguration
PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
<properties
resource=
"db.properties"
/>
<!--导入属性配置 -->
<context
id=
"default"
targetRuntime=
"MyBatis3"
>
<!-- 插件 -->
<plugin
type=
"com.itfsw.mybatis.generator.plugins.SelectiveEnhancedPlugin"
/>
<plugin
type=
"com.itfsw.mybatis.generator.plugins.ModelColumnPlugin"
/>
<plugin
type=
"com.itfsw.mybatis.generator.plugins.UpsertPlugin"
/>
<!--jdbc的数据库连接 -->
<jdbcConnection
driverClass=
"${driver}"
connectionURL=
"${url}"
userId=
"${username}"
password=
"${password}"
/>
<!-- Model模型生成器,用来生成含有主键key的类,记录类 以及查询Example类
targetPackage 指定生成的model生成所在的包名
targetProject 指定在该项目下所在的路径 -->
<javaModelGenerator
targetPackage=
""
targetProject=
""
/>
<!--Mapper映射文件生成所在的目录 为每一个数据库的表生成对应的SqlMap文件 -->
<sqlMapGenerator
targetPackage=
""
targetProject=
""
/>
<!-- 客户端代码,生成易于使用的针对Model对象和XML配置文件 的代码
type="ANNOTATEDMAPPER",生成Java Model 和基于注解的Mapper对象
type="MIXEDMAPPER",生成基于注解的Java Model 和相应的Mapper对象
type="XMLMAPPER",生成SQLMap XML文件和独立的Mapper接口 -->
<javaClientGenerator
targetPackage=
""
targetProject=
""
type=
"XMLMAPPER"
/>
<!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 要自动生成的表 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<table
tableName=
"tb"
>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
<columnOverride
column=
"inc_f2"
property=
"tsIncF2"
/>
</table>
</context>
</generatorConfiguration>
\ No newline at end of file
src/test/resources/scripts/SelectiveEnhancedPlugin/mybatis-generator-without-ModelColumnPlugin.xml
0 → 100644
View file @
8e56ee0d
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2017.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<!DOCTYPE generatorConfiguration
PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
<properties
resource=
"db.properties"
/>
<!--导入属性配置 -->
<context
id=
"default"
targetRuntime=
"MyBatis3"
>
<!-- 插件 -->
<plugin
type=
"com.itfsw.mybatis.generator.plugins.SelectiveEnhancedPlugin"
/>
<!--jdbc的数据库连接 -->
<jdbcConnection
driverClass=
"${driver}"
connectionURL=
"${url}"
userId=
"${username}"
password=
"${password}"
/>
<!-- Model模型生成器,用来生成含有主键key的类,记录类 以及查询Example类
targetPackage 指定生成的model生成所在的包名
targetProject 指定在该项目下所在的路径 -->
<javaModelGenerator
targetPackage=
""
targetProject=
""
/>
<!--Mapper映射文件生成所在的目录 为每一个数据库的表生成对应的SqlMap文件 -->
<sqlMapGenerator
targetPackage=
""
targetProject=
""
/>
<!-- 客户端代码,生成易于使用的针对Model对象和XML配置文件 的代码
type="ANNOTATEDMAPPER",生成Java Model 和基于注解的Mapper对象
type="MIXEDMAPPER",生成基于注解的Java Model 和相应的Mapper对象
type="XMLMAPPER",生成SQLMap XML文件和独立的Mapper接口 -->
<javaClientGenerator
targetPackage=
""
targetProject=
""
type=
"XMLMAPPER"
/>
<!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 要自动生成的表 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<table
tableName=
"tb"
>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
<columnOverride
column=
"inc_f2"
property=
"tsIncF2"
/>
</table>
</context>
</generatorConfiguration>
\ No newline at end of file
src/test/resources/scripts/SelectiveEnhancedPlugin/mybatis-generator.xml
0 → 100644
View file @
8e56ee0d
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2017.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<!DOCTYPE generatorConfiguration
PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
<properties
resource=
"db.properties"
/>
<!--导入属性配置 -->
<context
id=
"default"
targetRuntime=
"MyBatis3"
>
<!-- 插件 -->
<plugin
type=
"com.itfsw.mybatis.generator.plugins.UpsertPlugin"
>
<property
name=
"allowMultiQueries"
value=
"true"
/>
</plugin>
<plugin
type=
"com.itfsw.mybatis.generator.plugins.SelectiveEnhancedPlugin"
/>
<plugin
type=
"com.itfsw.mybatis.generator.plugins.ModelColumnPlugin"
/>
<!--jdbc的数据库连接 -->
<jdbcConnection
driverClass=
"${driver}"
connectionURL=
"${url}"
userId=
"${username}"
password=
"${password}"
/>
<!-- Model模型生成器,用来生成含有主键key的类,记录类 以及查询Example类
targetPackage 指定生成的model生成所在的包名
targetProject 指定在该项目下所在的路径 -->
<javaModelGenerator
targetPackage=
""
targetProject=
""
/>
<!--Mapper映射文件生成所在的目录 为每一个数据库的表生成对应的SqlMap文件 -->
<sqlMapGenerator
targetPackage=
""
targetProject=
""
/>
<!-- 客户端代码,生成易于使用的针对Model对象和XML配置文件 的代码
type="ANNOTATEDMAPPER",生成Java Model 和基于注解的Mapper对象
type="MIXEDMAPPER",生成基于注解的Java Model 和相应的Mapper对象
type="XMLMAPPER",生成SQLMap XML文件和独立的Mapper接口 -->
<javaClientGenerator
targetPackage=
""
targetProject=
""
type=
"XMLMAPPER"
/>
<!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 要自动生成的表 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<table
tableName=
"tb"
>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
<columnOverride
column=
"inc_f2"
property=
"tsIncF2"
/>
</table>
</context>
</generatorConfiguration>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment