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
|
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="cn.learn.dao.EmployeesMapper" > -- 下面会写这个类
<resultMap id="BaseResultMap" type="cn.learn.pojo.Employees" > -- 实体类的全类名, 可以任意, 不顾一般都是按照表名写
<id column="EMPLOYEE_ID" property="employeeId" jdbcType="DECIMAL" />
<result column="FIRST_NAME" property="firstName" jdbcType="VARCHAR" />
<result column="LAST_NAME" property="lastName" jdbcType="VARCHAR" />
<result column="EMAIL" property="email" jdbcType="VARCHAR" />
<result column="PHONE_NUMBER" property="phoneNumber" jdbcType="VARCHAR" />
<result column="HIRE_DATE" property="hireDate" jdbcType="DATE" />
<result column="JOB_ID" property="jobId" jdbcType="VARCHAR" />
<result column="SALARY" property="salary" jdbcType="DECIMAL" />
<result column="COMMISSION_PCT" property="commissionPct" jdbcType="DECIMAL" />
<result column="MANAGER_ID" property="managerId" jdbcType="DECIMAL" />
<result column="DEPARTMENT_ID" property="departmentId" jdbcType="DECIMAL" />
</resultMap>
<sql id="Base_Column_List" >
EMPLOYEE_ID, FIRST_NAME, LAST_NAME, EMAIL, PHONE_NUMBER, HIRE_DATE, JOB_ID, SALARY,
COMMISSION_PCT, MANAGER_ID, DEPARTMENT_ID
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from EMPLOYEES
where EMPLOYEE_ID = #{employeeId,jdbcType=DECIMAL}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from EMPLOYEES
where EMPLOYEE_ID = #{employeeId,jdbcType=DECIMAL}
</delete>
<insert id="insert" parameterType="cn.learn.pojo.Employees" >
insert into EMPLOYEES (EMPLOYEE_ID, FIRST_NAME, LAST_NAME,
EMAIL, PHONE_NUMBER, HIRE_DATE,
JOB_ID, SALARY, COMMISSION_PCT,
MANAGER_ID, DEPARTMENT_ID)
values (#{employeeId,jdbcType=DECIMAL}, #{firstName,jdbcType=VARCHAR}, #{lastName,jdbcType=VARCHAR},
#{email,jdbcType=VARCHAR}, #{phoneNumber,jdbcType=VARCHAR}, #{hireDate,jdbcType=DATE},
#{jobId,jdbcType=VARCHAR}, #{salary,jdbcType=DECIMAL}, #{commissionPct,jdbcType=DECIMAL},
#{managerId,jdbcType=DECIMAL}, #{departmentId,jdbcType=DECIMAL})
</insert>
<insert id="insertSelective" parameterType="cn.learn.pojo.Employees" >
insert into EMPLOYEES
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="employeeId != null" >
EMPLOYEE_ID,
</if>
<if test="firstName != null" >
FIRST_NAME,
</if>
<if test="lastName != null" >
LAST_NAME,
</if>
<if test="email != null" >
EMAIL,
</if>
<if test="phoneNumber != null" >
PHONE_NUMBER,
</if>
<if test="hireDate != null" >
HIRE_DATE,
</if>
<if test="jobId != null" >
JOB_ID,
</if>
<if test="salary != null" >
SALARY,
</if>
<if test="commissionPct != null" >
COMMISSION_PCT,
</if>
<if test="managerId != null" >
MANAGER_ID,
</if>
<if test="departmentId != null" >
DEPARTMENT_ID,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="employeeId != null" >
#{employeeId,jdbcType=DECIMAL},
</if>
<if test="firstName != null" >
#{firstName,jdbcType=VARCHAR},
</if>
<if test="lastName != null" >
#{lastName,jdbcType=VARCHAR},
</if>
<if test="email != null" >
#{email,jdbcType=VARCHAR},
</if>
<if test="phoneNumber != null" >
#{phoneNumber,jdbcType=VARCHAR},
</if>
<if test="hireDate != null" >
#{hireDate,jdbcType=DATE},
</if>
<if test="jobId != null" >
#{jobId,jdbcType=VARCHAR},
</if>
<if test="salary != null" >
#{salary,jdbcType=DECIMAL},
</if>
<if test="commissionPct != null" >
#{commissionPct,jdbcType=DECIMAL},
</if>
<if test="managerId != null" >
#{managerId,jdbcType=DECIMAL},
</if>
<if test="departmentId != null" >
#{departmentId,jdbcType=DECIMAL},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="cn.learn.pojo.Employees" >
update EMPLOYEES
<set >
<if test="firstName != null" >
FIRST_NAME = #{firstName,jdbcType=VARCHAR},
</if>
<if test="lastName != null" >
LAST_NAME = #{lastName,jdbcType=VARCHAR},
</if>
<if test="email != null" >
EMAIL = #{email,jdbcType=VARCHAR},
</if>
<if test="phoneNumber != null" >
PHONE_NUMBER = #{phoneNumber,jdbcType=VARCHAR},
</if>
<if test="hireDate != null" >
HIRE_DATE = #{hireDate,jdbcType=DATE},
</if>
<if test="jobId != null" >
JOB_ID = #{jobId,jdbcType=VARCHAR},
</if>
<if test="salary != null" >
SALARY = #{salary,jdbcType=DECIMAL},
</if>
<if test="commissionPct != null" >
COMMISSION_PCT = #{commissionPct,jdbcType=DECIMAL},
</if>
<if test="managerId != null" >
MANAGER_ID = #{managerId,jdbcType=DECIMAL},
</if>
<if test="departmentId != null" >
DEPARTMENT_ID = #{departmentId,jdbcType=DECIMAL},
</if>
</set>
where EMPLOYEE_ID = #{employeeId,jdbcType=DECIMAL}
</update>
<update id="updateByPrimaryKey" parameterType="cn.learn.pojo.Employees" >
update EMPLOYEES
set FIRST_NAME = #{firstName,jdbcType=VARCHAR},
LAST_NAME = #{lastName,jdbcType=VARCHAR},
EMAIL = #{email,jdbcType=VARCHAR},
PHONE_NUMBER = #{phoneNumber,jdbcType=VARCHAR},
HIRE_DATE = #{hireDate,jdbcType=DATE},
JOB_ID = #{jobId,jdbcType=VARCHAR},
SALARY = #{salary,jdbcType=DECIMAL},
COMMISSION_PCT = #{commissionPct,jdbcType=DECIMAL},
MANAGER_ID = #{managerId,jdbcType=DECIMAL},
DEPARTMENT_ID = #{departmentId,jdbcType=DECIMAL}
where EMPLOYEE_ID = #{employeeId,jdbcType=DECIMAL}
</update>
</mapper>
|