SequenceKeyDao.xml
2.22 KB
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
<?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="com.diligrp.assistant.uid.dao.SequenceKeyDao">
<resultMap id="PersistentKeyMap" type="com.diligrp.assistant.uid.domain.PersistentSequenceKey">
<id column="id" property="id"/>
<result column="key" property="key"/>
<result column="name" property="name"/>
<result column="value" property="value"/>
<result column="step" property="step"/>
<result column="pattern" property="pattern"/>
<result column="expired_on" property="expiredOn"/>
<result column="today" property="today"/>
<result column="version" property="version"/>
</resultMap>
<insert id="insertSequenceKey" parameterType="com.diligrp.assistant.uid.domain.PersistentSequenceKey">
INSERT INTO uid_sequence_key(`key`, name, value, step, pattern, expired_on, version)
VALUES (#{key}, #{name}, #{value}, #{step}, #{pattern}, #{expiredOn}, #{version})
</insert>
<select id="findSequenceKey" parameterType="string" resultMap="PersistentKeyMap">
SELECT
id, `key`, name, value, step, pattern, expired_on, curdate() AS today, version
FROM
uid_sequence_key
WHERE
`key` = #{key}
</select>
<select id="findSequenceKeyById" parameterType="long" resultMap="PersistentKeyMap">
SELECT
id, `key`, name, value, step, pattern, expired_on, curdate() AS today, version
FROM
uid_sequence_key
WHERE
id = #{id}
</select>
<select id="lockSequenceKey" parameterType="long" resultMap="PersistentKeyMap">
SELECT
id, `key`, name, value, step, pattern, expired_on, curdate() AS today, version
FROM
uid_sequence_key
WHERE
id = #{id}
FOR UPDATE
</select>
<update id="unlockSequenceKey" parameterType="com.diligrp.assistant.uid.domain.PersistentSequenceKey">
UPDATE
uid_sequence_key
SET
value = #{value}, expired_on = #{expiredOn}, version = version + 1
WHERE
id = #{id}
</update>
</mapper>