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
e4164726
Commit
e4164726
authored
May 16, 2018
by
hewei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ModelColumnPlugin增加excludes方法
parent
ba73f0ac
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
0 deletions
+18
-0
README.md
README.md
+18
-0
No files found.
README.md
View file @
e4164726
...
...
@@ -346,6 +346,8 @@ public class Test {
this
.
tbMapper
.
batchInsert
(
list
);
// !!!下面按需插入指定列(类似于insertSelective),需要数据Model属性对应Column获取插件(ModelColumnPlugin)插件
this
.
tbMapper
.
batchInsertSelective
(
list
,
Tb
.
Column
.
field1
,
Tb
.
Column
.
field2
,
Tb
.
Column
.
field3
,
Tb
.
Column
.
createTime
);
// 或者排除某些列
this
.
tbMapper
.
batchInsertSelective
(
list
,
Tb
.
Column
.
excludes
(
Tb
.
Column
.
id
,
Tb
.
Column
.
delFlag
));
}
}
```
...
...
@@ -427,6 +429,7 @@ public class Test {
项目中我们有时需要获取数据Model对应数据库字段的名称,一般直接根据数据Model的属性就可以猜出数据库对应column的名字,可是有的时候当column使用了columnOverride或者columnRenamingRule时就需要去看数据库设计了,所以提供了这个插件获取model对应的数据库Column。
*
配合Example Criteria 增强插件(ExampleEnhancedPlugin)使用,这个插件还提供了asc()和desc()方法配合Example的orderBy方法效果更佳。
*
配合批量插入插件(BatchInsertPlugin)使用,batchInsertSelective(@Param("list") List
<XXX>
list, @Param("selective") XXX.Column ... insertColumns)。
*
提供静态excludes方法来进行快速反选。
插件:
```
xml
...
...
@@ -481,6 +484,9 @@ public class Test {
this
.
tbMapper
.
batchInsert
(
list
);
// 下面按需插入指定列(类似于insertSelective)
this
.
tbMapper
.
batchInsertSelective
(
list
,
Tb
.
Column
.
field1
,
Tb
.
Column
.
field2
,
Tb
.
Column
.
field3
,
Tb
.
Column
.
createTime
);
// 4. excludes 方法
this
.
tbMapper
.
batchInsertSelective
(
list
,
Tb
.
Column
.
excludes
(
Tb
.
Column
.
id
,
Tb
.
Column
.
delFlag
));
}
}
```
...
...
@@ -607,6 +613,9 @@ public class Test {
.
build
(),
Tb
.
Column
.
field1
);
// 3. 排除某些列
this
.
tbMapper
.
insertSelective
(
tb
,
Tb
.
Column
.
excludes
(
Tb
.
Column
.
id
,
Tb
.
Column
.
delFlag
));
}
}
```
...
...
@@ -1075,6 +1084,15 @@ public class Test {
Tb
.
Column
.
field2
);
// 同理还有 selectByPrimaryKeySelective,selectOneByExampleSelective(SelectOneByExamplePlugin插件配合使用)方法
// 当然可以使用excludes
this
.
tbMapper
.
selectByExampleSelective
(
new
TbExample
()
.
createCriteria
()
.
andField1GreaterThan
(
1
)
.
example
(),
Tb
.
Column
.
excludes
(
Tb
.
Column
.
id
,
Tb
.
Column
.
delFlag
)
);
}
}
```
...
...
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