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
8aad55aa
Commit
8aad55aa
authored
Aug 09, 2018
by
hewei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bugfix[issues#36]:ExampleEnhancedPlugin在列比较时对于typeHandler处理有问题
parent
4aab6080
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
103 additions
and
10 deletions
+103
-10
src/main/java/com/itfsw/mybatis/generator/plugins/ExampleEnhancedPlugin.java
...tfsw/mybatis/generator/plugins/ExampleEnhancedPlugin.java
+1
-10
src/test/java/com/itfsw/mybatis/generator/plugins/BugFixedTest.java
...ava/com/itfsw/mybatis/generator/plugins/BugFixedTest.java
+15
-0
src/test/resources/scripts/BugFixedTest/issues-36.sql
src/test/resources/scripts/BugFixedTest/issues-36.sql
+27
-0
src/test/resources/scripts/BugFixedTest/issues-36.xml
src/test/resources/scripts/BugFixedTest/issues-36.xml
+60
-0
No files found.
src/main/java/com/itfsw/mybatis/generator/plugins/ExampleEnhancedPlugin.java
View file @
8aad55aa
...
...
@@ -13,8 +13,6 @@ import org.mybatis.generator.codegen.mybatis3.MyBatis3FormattingUtilities;
import
java.util.List
;
import
static
org
.
mybatis
.
generator
.
internal
.
util
.
StringUtility
.
stringHasValue
;
/**
* ---------------------------------------------------------------------------
* Example 增强插件
...
...
@@ -130,14 +128,7 @@ public class ExampleEnhancedPlugin extends BasePlugin {
// 方法体
sb
.
setLength
(
0
);
if
(
stringHasValue
(
introspectedColumn
.
getTypeHandler
()))
{
sb
.
append
(
"add"
);
sb
.
append
(
introspectedColumn
.
getJavaProperty
());
sb
.
setCharAt
(
3
,
Character
.
toUpperCase
(
sb
.
charAt
(
3
)));
sb
.
append
(
"Criterion("
);
}
else
{
sb
.
append
(
"addCriterion("
);
}
sb
.
append
(
"addCriterion("
);
sb
.
append
(
"new StringBuilder(\""
);
sb
.
append
(
MyBatis3FormattingUtilities
.
getAliasedActualColumnName
(
introspectedColumn
));
sb
.
append
(
" "
);
...
...
src/test/java/com/itfsw/mybatis/generator/plugins/BugFixedTest.java
View file @
8aad55aa
...
...
@@ -108,6 +108,21 @@ public class BugFixedTest {
});
}
/**
* typeHandler 导致的问题
*/
@Test
public
void
issues36
()
throws
Exception
{
MyBatisGeneratorTool
tool
=
MyBatisGeneratorTool
.
create
(
"scripts/BugFixedTest/issues-36.xml"
);
tool
.
generate
(()
->
DBHelper
.
createDB
(
"scripts/BugFixedTest/issues-36.sql"
),
new
AbstractShellCallback
()
{
@Override
public
void
reloadProject
(
SqlSession
sqlSession
,
ClassLoader
loader
,
String
packagz
)
throws
Exception
{
// Example 编译报错
new
ObjectUtil
(
loader
,
packagz
+
".TbExample"
);
}
});
}
/**
* 乐观锁插件好像变量作用域问题导致,前一个表的配置会影响后一个表配置
*/
...
...
src/test/resources/scripts/BugFixedTest/issues-36.sql
0 → 100644
View file @
8aad55aa
/*
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-06-27 11:17:08
*/
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'
,
`field1`
varchar
(
255
)
DEFAULT
NULL
COMMENT
'注释2'
,
`t_date`
date
DEFAULT
NULL
,
PRIMARY
KEY
(
`id`
)
)
ENGINE
=
MyISAM
DEFAULT
CHARSET
=
utf8
;
\ No newline at end of file
src/test/resources/scripts/BugFixedTest/issues-36.xml
0 → 100644
View file @
8aad55aa
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2018.
~
~ 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"
>
<property
name=
"autoDelimitKeywords"
value=
"true"
/>
<property
name=
"beginningDelimiter"
value=
"`"
/>
<property
name=
"endingDelimiter"
value=
"`"
/>
<!-- 数据Model属性对应Column获取插件 -->
<plugin
type=
"com.itfsw.mybatis.generator.plugins.ModelColumnPlugin"
/>
<!-- Selective选择插入更新增强插件 -->
<plugin
type=
"com.itfsw.mybatis.generator.plugins.SelectiveEnhancedPlugin"
/>
<!-- Example Criteria 增强插件 -->
<plugin
type=
"com.itfsw.mybatis.generator.plugins.ExampleEnhancedPlugin"
/>
<!--jdbc的数据库连接 -->
<jdbcConnection
driverClass=
"${driver}"
connectionURL=
"${url}"
userId=
"${username}"
password=
"${password}"
/>
<!-- Model模型生成器,用来生成含有主键key的类,记录类 以及查询Example类
targetPackage 指定生成的model生成所在的包名
targetProject 指定在该项目下所在的路径 -->
<javaModelGenerator
targetPackage=
""
targetProject=
""
>
<!-- 是否对model添加 构造函数 -->
<property
name=
"constructorBased"
value=
"true"
/>
<!-- 给Model添加一个父类 -->
<!--<property name="rootClass" value="com.itfsw.base"/>-->
</javaModelGenerator>
<!--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"
>
<columnOverride
column=
"field1"
javaType=
"java.sql.Array"
typeHandler=
"org.apache.ibatis.type.ArrayTypeHandler"
/>
</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