1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
<?
xml
version
=
"1.0"
encoding
=
"UTF-8"
?>
<!DOCTYPE generatorConfiguration
PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<
generatorConfiguration
>
<!-- classPathEntry:数据库的JDBC驱动的jar包地址-->
<
classPathEntry
location
=
"E:\jar\mysql-connector-java-5.1.39\mysql-connector-java-5.1.39\mysql-connector-java-5.1.39-bin.jar"
/>
<
context
id
=
"MysqlTables"
targetRuntime
=
"MyBatis3"
>
<!-- 注释 -->
<
commentGenerator
>
<
property
name
=
"suppressAllComments"
value
=
"true"
/>
<!-- 是否取消注释 -->
<
property
name
=
"suppressDate"
value
=
"true"
/>
<!-- 是否生成注释代时间戳-->
</
commentGenerator
>
<!-- JDBC连接 -->
<
jdbcConnection
driverClass
=
"com.mysql.jdbc.Driver"
connectionURL
=
"jdbc:mysql://127.0.0.1:3306/jycps?useUnicode=true&characterEncoding=UTF-8"
userId
=
"root"
password
=
"root"
>
</
jdbcConnection
>
<!-- 类型转换 -->
<
javaTypeResolver
>
<!-- 是否使用bigDecimal, false可自动转化以下类型(Long, Integer, Short, etc.) -->
<
property
name
=
"forceBigDecimals"
value
=
"false"
/>
</
javaTypeResolver
>
<!-- 生成实体类地址 -->
<
javaModelGenerator
targetPackage
=
"com.jiayou.cps.pojo"
targetProject
=
"D:\workspace\jy_cps\jy_cps\src\main\java"
>
<
property
name
=
"enableSubPackages"
value
=
"true"
/>
<!-- 是否在当前路径下新加一层-->
<
property
name
=
"trimStrings"
value
=
"true"
/>
<!-- 是否针对string类型的字段在set的时候进行trim调用 -->
</
javaModelGenerator
>
<!-- 生成MAPXML文件 -->
<
sqlMapGenerator
targetPackage
=
"sqlmap/test"
targetProject
=
"D:\workspace\jy_cps\jy_cps\src\main\resources"
>
<
property
name
=
"enableSubPackages"
value
=
"true"
/>
<!-- 是否在当前路径下新加一层-->
</
sqlMapGenerator
>
<!-- 生成DAO -->
<
javaClientGenerator
type
=
"XMLMAPPER"
targetPackage
=
"com.jiayou.cps.dao"
targetProject
=
"D:\workspace\jy_cps\jy_cps\src\main\java"
>
<
property
name
=
"enableSubPackages"
value
=
"true"
/>
<!-- 是否在当前路径下新加一层-->
</
javaClientGenerator
>
<!-- 配置表信息 -->
<
table
schema
=
""
tableName
=
"tb_test"
domainObjectName
=
"Test"
enableCountByExample
=
"true"
enableUpdateByExample
=
"true"
enableDeleteByExample
=
"true"
enableSelectByExample
=
"true"
selectByExampleQueryId
=
"true"
>
</
table
>
</
context
>
</
generatorConfiguration
>
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
package
com.jiayou.cps.dao;
import
com.jiayou.cps.pojo.Test;
import
com.jiayou.cps.pojo.TestExample;
import
java.util.List;
import
org.apache.ibatis.annotations.Param;
public
interface
TestMapper {
int
countByExample(TestExample example);
int
deleteByExample(TestExample example);
int
deleteByPrimaryKey(Integer tbId);
int
insert(Test record);
int
insertSelective(Test record);
List<Test> selectByExample(TestExample example);
Test selectByPrimaryKey(Integer tbId);
int
updateByExampleSelective(
@Param
(
"record"
) Test record,
@Param
(
"example"
) TestExample example);
int
updateByExample(
@Param
(
"record"
) Test record,
@Param
(
"example"
) TestExample example);
int
updateByPrimaryKeySelective(Test record);
int
updateByPrimaryKey(Test record);
}
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
package
com.jiayou.cps.pojo;
public
class
Test {
private
Integer tbId;
private
String tbName;
public
Integer getTbId() {
return
tbId;
}
public
void
setTbId(Integer tbId) {
this
.tbId = tbId;
}
public
String getTbName() {
return
tbName;
}
public
void
setTbName(String tbName) {
this
.tbName = tbName ==
null
?
null
: tbName.trim();
}
}
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
|
package
com.jiayou.cps.pojo;
import
java.util.ArrayList;
import
java.util.List;
import
com.jiayou.cps.mybatis.page.BaseExample;
public
class
TestExample
extends
BaseExample{
protected
String orderByClause;
protected
boolean
distinct;
protected
List<Criteria> oredCriteria;
public
TestExample() {
oredCriteria =
new
ArrayList<Criteria>();
}
public
void
setOrderByClause(String orderByClause) {
this
.orderByClause = orderByClause;
}
public
String getOrderByClause() {
return
orderByClause;
}
public
void
setDistinct(
boolean
distinct) {
this
.distinct = distinct;
}
public
boolean
isDistinct() {
return
distinct;
}
public
List<Criteria> getOredCriteria() {
return
oredCriteria;
}
public
void
or(Criteria criteria) {
oredCriteria.add(criteria);
}
public
Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return
criteria;
}
public
Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if
(oredCriteria.size() ==
0
) {
oredCriteria.add(criteria);
}
return
criteria;
}
protected
Criteria createCriteriaInternal() {
Criteria criteria =
new
Criteria();
return
criteria;
}
public
void
clear() {
oredCriteria.clear();
orderByClause =
null
;
distinct =
false
;
}
protected
abstract
static
class
GeneratedCriteria {
protected
List<Criterion> criteria;
protected
GeneratedCriteria() {
super
();
criteria =
new
ArrayList<Criterion>();
}
public
boolean
isValid() {
return
criteria.size() >
0
;
}
public
List<Criterion> getAllCriteria() {
return
criteria;
}
public
List<Criterion> getCriteria() {
return
criteria;
}
protected
void
addCriterion(String condition) {
if
(condition ==
null
) {
throw
new
RuntimeException(
"Value for condition cannot be null"
);
}
criteria.add(
new
Criterion(condition));
}
protected
void
addCriterion(String condition, Object value, String property) {
if
(value ==
null
) {
throw
new
RuntimeException(
"Value for "
+ property +
" cannot be null"
);
}
criteria.add(
new
Criterion(condition, value));
}
protected
void
addCriterion(String condition, Object value1, Object value2, String property) {
if
(value1 ==
null
|| value2 ==
null
) {
throw
new
RuntimeException(
"Between values for "
+ property +
" cannot be null"
);
}
criteria.add(
new
Criterion(condition, value1, value2));
}
public
Criteria andTbIdIsNull() {
addCriterion(
"tb_id is null"
);
return
(Criteria)
this
;
}
public
Criteria andTbIdIsNotNull() {
addCriterion(
"tb_id is not null"
);
return
(Criteria)
this
;
}
public
Criteria andTbIdEqualTo(Integer value) {
addCriterion(
"tb_id ="
, value,
"tbId"
);
return
(Criteria)
this
;
}
public
Criteria andTbIdNotEqualTo(Integer value) {
addCriterion(
"tb_id <>"
, value,
"tbId"
);
return
(Criteria)
this
;
}
public
Criteria andTbIdGreaterThan(Integer value) {
addCriterion(
"tb_id >"
, value,
"tbId"
);
return
(Criteria)
this
;
}
public
Criteria andTbIdGreaterThanOrEqualTo(Integer value) {
addCriterion(
"tb_id >="
, value,
"tbId"
);
return
(Criteria)
this
;
}
public
Criteria andTbIdLessThan(Integer value) {
addCriterion(
"tb_id <"
, value,
"tbId"
);
return
(Criteria)
this
;
}
public
Criteria andTbIdLessThanOrEqualTo(Integer value) {
addCriterion(
"tb_id <="
, value,
"tbId"
);
return
(Criteria)
this
;
}
public
Criteria andTbIdIn(List<Integer> values) {
addCriterion(
"tb_id in"
, values,
"tbId"
);
return
(Criteria)
this
;
}
public
Criteria andTbIdNotIn(List<Integer> values) {
addCriterion(
"tb_id not in"
, values,
"tbId"
);
return
(Criteria)
this
;
}
public
Criteria andTbIdBetween(Integer value1, Integer value2) {
addCriterion(
"tb_id between"
, value1, value2,
"tbId"
);
return
(Criteria)
this
;
}
public
Criteria andTbIdNotBetween(Integer value1, Integer value2) {
addCriterion(
"tb_id not between"
, value1, value2,
"tbId"
);
return
(Criteria)
this
;
}
public
Criteria andTbNameIsNull() {
addCriterion(
"tb_name is null"
);
return
(Criteria)
this
;
}
public
Criteria andTbNameIsNotNull() {
addCriterion(
"tb_name is not null"
);
return
(Criteria)
this
;
}
public
Criteria andTbNameEqualTo(String value) {
addCriterion(
"tb_name ="
, value,
"tbName"
);
return
(Criteria)
this
;
}
public
Criteria andTbNameNotEqualTo(String value) {
addCriterion(
"tb_name <>"
, value,
"tbName"
);
return
(Criteria)
this
;
}
public
Criteria andTbNameGreaterThan(String value) {
addCriterion(
"tb_name >"
, value,
"tbName"
);
return
(Criteria)
this
;
}
public
Criteria andTbNameGreaterThanOrEqualTo(String value) {
addCriterion(
"tb_name >="
, value,
"tbName"
);
return
(Criteria)
this
;
}
public
Criteria andTbNameLessThan(String value) {
addCriterion(
"tb_name <"
, value,
"tbName"
);
return
(Criteria)
this
;
}
public
Criteria andTbNameLessThanOrEqualTo(String value) {
addCriterion(
"tb_name <="
, value,
"tbName"
);
return
(Criteria)
this
;
}
public
Criteria andTbNameLike(String value) {
addCriterion(
"tb_name like"
, value,
"tbName"
);
return
(Criteria)
this
;
}
public
Criteria andTbNameNotLike(String value) {
addCriterion(
"tb_name not like"
, value,
"tbName"
);
return
(Criteria)
this
;
}
public
Criteria andTbNameIn(List<String> values) {
addCriterion(
"tb_name in"
, values,
"tbName"
);
return
(Criteria)
this
;
}
public
Criteria andTbNameNotIn(List<String> values) {
addCriterion(
"tb_name not in"
, values,
"tbName"
);
return
(Criteria)
this
;
}
public
Criteria andTbNameBetween(String value1, String value2) {
addCriterion(
"tb_name between"
, value1, value2,
"tbName"
);
return
(Criteria)
this
;
}
public
Criteria andTbNameNotBetween(String value1, String value2) {
addCriterion(
"tb_name not between"
, value1, value2,
"tbName"
);
return
(Criteria)
this
;
}
}
public
static
class
Criteria
extends
GeneratedCriteria {
protected
Criteria() {
super
();
}
}
public
static
class
Criterion {
private
String condition;
private
Object value;
private
Object secondValue;
private
boolean
noValue;
private
boolean
singleValue;
private
boolean
betweenValue;
private
boolean
listValue;
private
String typeHandler;
public
String getCondition() {
return
condition;
}
public
Object getValue() {
return
value;
}
public
Object getSecondValue() {
return
secondValue;
}
public
boolean
isNoValue() {
return
noValue;
}
public
boolean
isSingleValue() {
return
singleValue;
}
public
boolean
isBetweenValue() {
return
betweenValue;
}
public
boolean
isListValue() {
return
listValue;
}
public
String getTypeHandler() {
return
typeHandler;
}
protected
Criterion(String condition) {
super
();
this
.condition = condition;
this
.typeHandler =
null
;
this
.noValue =
true
;
}
protected
Criterion(String condition, Object value, String typeHandler) {
super
();
this
.condition = condition;
this
.value = value;
this
.typeHandler = typeHandler;
if
(value
instanceof
List<?>) {
this
.listValue =
true
;
}
else
{
this
.singleValue =
true
;
}
}
protected
Criterion(String condition, Object value) {
this
(condition, value,
null
);
}
protected
Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super
();
this
.condition = condition;
this
.value = value;
this
.secondValue = secondValue;
this
.typeHandler = typeHandler;
this
.betweenValue =
true
;
}
protected
Criterion(String condition, Object value, Object secondValue) {
this
(condition, value, secondValue,
null
);
}
}
}
|