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
2571f1c5
Commit
2571f1c5
authored
May 17, 2017
by
hewei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
对于Model生成WithBLOBs类时,upsert插件实现行为和官方插件保持一致
parent
30a3539f
Changes
2
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
238 additions
and
26 deletions
+238
-26
src/main/java/com/itfsw/mybatis/generator/plugins/SelectiveEnhancedPlugin.java
...sw/mybatis/generator/plugins/SelectiveEnhancedPlugin.java
+22
-3
src/main/java/com/itfsw/mybatis/generator/plugins/UpsertPlugin.java
...ava/com/itfsw/mybatis/generator/plugins/UpsertPlugin.java
+216
-23
No files found.
src/main/java/com/itfsw/mybatis/generator/plugins/SelectiveEnhancedPlugin.java
View file @
2571f1c5
...
...
@@ -169,14 +169,32 @@ public class SelectiveEnhancedPlugin extends BasePlugin {
List
<
XmlElement
>
eles
=
this
.
findEle
(
xmlElement
,
"trim"
);
this
.
replaceEle
(
eles
.
get
(
0
),
"record."
);
// upsertByExampleSelective的第二个trim比较特殊,需另行处理
this
.
replaceEleForUpsertByExampleSelective
(
eles
.
get
(
1
),
"record."
,
introspectedTable
);
this
.
replaceEleForUpsertByExampleSelective
(
eles
.
get
(
1
),
"record."
,
introspectedTable
,
false
);
List
<
XmlElement
>
eles1
=
this
.
findEle
(
xmlElement
,
"set"
);
for
(
XmlElement
ele
:
eles1
)
{
this
.
replaceEle
(
ele
,
"record."
);
}
}
// ====================================== 6. upsertSelectiveWithBLOBs ======================================
if
(
"upsertSelectiveWithBLOBs"
.
equals
(
id
))
{
List
<
XmlElement
>
eles
=
this
.
findEle
(
xmlElement
,
"trim"
);
for
(
XmlElement
ele
:
eles
)
{
this
.
replaceEle
(
ele
,
"_parameter."
);
}
}
// ====================================== 7. upsertByExampleSelectiveWithBLOBs ======================================
if
(
"upsertByExampleSelectiveWithBLOBs"
.
equals
(
id
))
{
List
<
XmlElement
>
eles
=
this
.
findEle
(
xmlElement
,
"trim"
);
this
.
replaceEle
(
eles
.
get
(
0
),
"record."
);
// upsertByExampleSelective的第二个trim比较特殊,需另行处理
this
.
replaceEleForUpsertByExampleSelective
(
eles
.
get
(
1
),
"record."
,
introspectedTable
,
true
);
List
<
XmlElement
>
eles1
=
this
.
findEle
(
xmlElement
,
"set"
);
for
(
XmlElement
ele
:
eles1
)
{
this
.
replaceEle
(
ele
,
"record."
);
}
}
}
}
return
true
;
...
...
@@ -262,14 +280,15 @@ public class SelectiveEnhancedPlugin extends BasePlugin {
* @param element
* @param prefix
* @param introspectedTable
* @param withBLOBs
*/
private
void
replaceEleForUpsertByExampleSelective
(
XmlElement
element
,
String
prefix
,
IntrospectedTable
introspectedTable
)
{
private
void
replaceEleForUpsertByExampleSelective
(
XmlElement
element
,
String
prefix
,
IntrospectedTable
introspectedTable
,
boolean
withBLOBs
)
{
// choose
XmlElement
chooseEle
=
new
XmlElement
(
"choose"
);
// when
XmlElement
whenEle
=
new
XmlElement
(
"when"
);
whenEle
.
addAttribute
(
new
Attribute
(
"test"
,
prefix
+
"isSelective()"
));
for
(
IntrospectedColumn
introspectedColumn
:
introspectedTable
.
getAll
Columns
())
{
for
(
IntrospectedColumn
introspectedColumn
:
withBLOBs
?
introspectedTable
.
getAllColumns
()
:
introspectedTable
.
getNonBLOB
Columns
())
{
XmlElement
eleIf
=
new
XmlElement
(
"if"
);
eleIf
.
addAttribute
(
new
Attribute
(
"test"
,
prefix
+
"isSelective(\'"
+
MyBatis3FormattingUtilities
.
getEscapedColumnName
(
introspectedColumn
)
+
"\')"
));
...
...
src/main/java/com/itfsw/mybatis/generator/plugins/UpsertPlugin.java
View file @
2571f1c5
This diff is collapsed.
Click to expand it.
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