-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEmployeeMapper.xml
67 lines (60 loc) · 2.5 KB
/
EmployeeMapper.xml
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
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE mapper PUBLIC '-//mybatis.org//DTD ConfigurationModels.Mapper 3.0//EN'
'http://mybatis.org/dtd/mybatis-3-mapper.dtd'>
<mapper namespace='Homework.MyRosko.EmployeeMapper'>
<cache
eviction="FIFO"
flushInterval="60000"
size="512"
readOnly="true"/>
<select id='getEmployeeById' parameterType='int' resultType='Employee' useCache="true">
SELECT employee_id as id,
email,
first_name as firstName,
last_name as lastName,
phone_number as phoneNumber,
salary,
hire_date as hireDate,
job_id as jobId,
manager_id as managerId,
department_id as departmentId
FROM employees
WHERE employee_id = #{value}
</select>
<resultMap type='Employee' id='EmployeeResult'>
<id property='id' column='employee_id'/>
<result property='email' column='email'/>
<result property='firstName' column='first_name'/>
<result property='lastName' column='last_name'/>
<result property='salary' column='salary'/>
<result property='hireDate' column='hire_date'/>
<result property='jobId' column='job_id'/>
<result property='managerId' column='manager_id'/>
<result property='departmentId' column='department_id'/>
</resultMap>
<select id='getAllEmployees' resultMap='EmployeeResult'>
SELECT *
FROM employees
</select>
<insert id='insertEmployee' parameterType='Employee' useGeneratedKeys='true' keyProperty='id'>
INSERT INTO employees(first_name, last_name, email, salary, hire_date, job_id, manager_id, department_id)
VALUES (#{firstName}, #{lastName}, #{email}, #{salary}, #{hireDate}, #{jobId}, #{managerId}, #{departmentId})
</insert>
<update id='updateEmployee' parameterType='Employee' flushCache="true">
UPDATE employees
SET first_name = #{firstName},
last_name = #{lastName},
email = #{email},
salary = #{salary},
hire_date = #{hireDate},
job_id = #{jobId},
manager_id = #{managerId},
department_id = #{departmentId}
WHERE employee_id = #{id}
</update>
<delete id='deleteEmployee' parameterType='int'>
DELETE
FROM employees
WHERE employee_id = #{value}
</delete>
</mapper>