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
464959ef
Commit
464959ef
authored
May 28, 2018
by
hewei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
TableRenameConfigurationPlugin
parent
074576f6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
7 deletions
+46
-7
README.md
README.md
+44
-5
src/test/resources/scripts/TableRenameConfigurationPlugin/mybatis-generator-with-columnRenamingRule.xml
...ationPlugin/mybatis-generator-with-columnRenamingRule.xml
+2
-2
No files found.
README.md
View file @
464959ef
...
@@ -1219,7 +1219,8 @@ public class Test {
...
@@ -1219,7 +1219,8 @@ public class Test {
```
```
### 18. 表重命名配置插件
### 18. 表重命名配置插件
官方提供了domainObjectRenamingRule(官方最新版本已提供)、columnRenamingRule分别进行生成的表名称和对应表字段的重命名支持,但是它需要每个表单独进行配置,对于常用的如表附带前缀“t_”、字段前缀“f_”这种全局性替换会比较麻烦。
官方提供了domainObjectRenamingRule(官方最新版本已提供)、columnRenamingRule分别进行生成的表名称和对应表字段的重命名支持,但是它需要每个表单独进行配置,对于常用的如表附带前缀“t_”、字段前缀“f_”这种全局性替换会比较麻烦。
该插件提供了一种全局替换机制,当表没有单独指定domainObjectRenamingRule、columnRenamingRule时采用全局性配置。同时该插件会修复官方domainObjectRenamingRule的bug(没有进行正确的首字母大写)。
该插件提供了一种全局替换机制,当表没有单独指定domainObjectRenamingRule、columnRenamingRule时采用全局性配置。同时该插件会修复官方domainObjectRenamingRule的bug(没有进行正确的首字母大写)。
同时插件提供clientSuffix、exampleSuffix、modelSuffix来修改对应生成的类和文件的结尾(之前issue中有用户希望能把Mapper替换成Dao)。
-
全局domainObjectRenamingRule
-
全局domainObjectRenamingRule
```
xml
```
xml
<xml>
<xml>
...
@@ -1230,10 +1231,48 @@ public class Test {
...
@@ -1230,10 +1231,48 @@ public class Test {
</plugin>
</plugin>
<table
tableName=
"tb"
>
<table
tableName=
"tb"
>
<!-- 这里可以单独表配置,覆盖全局配置 -->
<!-- 这里可以禁用全局domainObjectRenamingRule配置 -->
<property
name=
"customizedNextVersion"
value=
"false"
/>
<property
name=
"domainObjectRenamingRule.disable"
value=
"true"
/>
<!-- 指定版本列 -->
<property
name=
"versionColumn"
value=
"version"
/>
</table>
</table>
<table
tableName=
"tb_ts1"
>
<!-- 当然你也可以使用官方domainObjectRenamingRule的配置来覆盖全局配置 -->
<domainObjectRenamingRule
searchString=
"^Tb"
replaceString=
"B"
/>
</table>
</xml>
```
-
全局columnRenamingRule
```
xml
<xml>
<!-- 表重命名配置插件 -->
<plugin
type=
"com.itfsw.mybatis.generator.plugins.TableRenameConfigurationPlugin"
>
<!-- 需要注意,这里的正则和官方一样是比对替换都是原始表的column名称 -->
<property
name=
"columnRenamingRule.searchString"
value=
"^f_"
/>
<property
name=
"columnRenamingRule.replaceString"
value=
"_"
/>
</plugin>
<table
tableName=
"tb"
>
<!-- 这里可以禁用全局columnRenamingRule配置 -->
<property
name=
"columnRenamingRule.disable"
value=
"true"
/>
</table>
<table
tableName=
"tb_ts1"
>
<!-- 当然你也可以使用官方domainObjectRenamingRule的配置来覆盖全局配置 -->
<columnRenamingRule
searchString=
"^f_"
replaceString=
"_"
/>
</table>
</xml>
```
-
clientSuffix、exampleSuffix、modelSuffix
```
xml
<xml>
<!-- 表重命名配置插件 -->
<plugin
type=
"com.itfsw.mybatis.generator.plugins.TableRenameConfigurationPlugin"
>
<!-- TbMapper -->
TbDao, TbMapper.xml --> TbDao.xml -->
<property
name=
"clientSuffix"
value=
"Dao"
/>
<!-- TbExmaple -->
TbQuery -->
<property
name=
"exampleSuffix"
value=
"Query"
/>
<!-- Tb -->
TbEntity -->
<property
name=
"modelSuffix"
value=
"Entity"
/>
</plugin>
</xml>
</xml>
```
```
\ No newline at end of file
src/test/resources/scripts/TableRenameConfigurationPlugin/mybatis-generator-with-columnRenamingRule.xml
View file @
464959ef
...
@@ -25,8 +25,8 @@
...
@@ -25,8 +25,8 @@
<context
id=
"default"
targetRuntime=
"MyBatis3"
>
<context
id=
"default"
targetRuntime=
"MyBatis3"
>
<!-- 插件 -->
<!-- 插件 -->
<plugin
type=
"com.itfsw.mybatis.generator.plugins.TableRenameConfigurationPlugin"
>
<plugin
type=
"com.itfsw.mybatis.generator.plugins.TableRenameConfigurationPlugin"
>
<property
name=
"columnRenamingRule.searchString"
value=
"^inc"
/>
<property
name=
"columnRenamingRule.searchString"
value=
"^inc
_
"
/>
<property
name=
"columnRenamingRule.replaceString"
value=
"Increment"
/>
<property
name=
"columnRenamingRule.replaceString"
value=
"Increment
_
"
/>
</plugin>
</plugin>
<!--jdbc的数据库连接 -->
<!--jdbc的数据库连接 -->
...
...
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