Skip to content

Commit b83de26

Browse files
committed
Add XML mapper for selectKey update tests
1 parent 7ae92d3 commit b83de26

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
4+
Copyright 2009-2012 the original author or authors.
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
18+
-->
19+
<!DOCTYPE mapper PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN" "http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd">
20+
<mapper namespace="org.apache.ibatis.submitted.selectkey.AnnotatedMapper">
21+
<insert id="insertTable2WithSelectKeyWithKeyMapXml">
22+
<selectKey keyProperty="nameId,generatedName" keyColumn="ID,NAME_FRED" order="AFTER" resultType="java.util.Map">
23+
select id, name_fred from table2 where id = identity()
24+
</selectKey>
25+
insert into table2 (name) values(#{name})
26+
</insert>
27+
28+
<insert id="insertTable2WithSelectKeyWithKeyObjectXml">
29+
<selectKey keyProperty="nameId,generatedName" order="AFTER" resultType="org.apache.ibatis.submitted.selectkey.Name">
30+
select id as nameId, name_fred as generatedName from table2 where id = identity()
31+
</selectKey>
32+
insert into table2 (name) values(#{name})
33+
</insert>
34+
35+
<insert id="insertTable2WithGeneratedKeyXml" useGeneratedKeys="true" keyProperty="nameId,generatedName" keyColumn="ID,NAME_FRED">
36+
insert into table2 (name) values(#{name})
37+
</insert>
38+
39+
<update id="updateTable2WithSelectKeyWithKeyMapXml">
40+
<selectKey keyProperty="generatedName" keyColumn="NAME_FRED" order="AFTER" resultType="java.lang.String">
41+
select name_fred from table2 where id = #{nameId}
42+
</selectKey>
43+
update table2 set name = #{name} where id = #{nameId}
44+
</update>
45+
46+
<update id="updateTable2WithSelectKeyWithKeyObjectXml">
47+
<selectKey keyProperty="generatedName" order="AFTER" resultType="org.apache.ibatis.submitted.selectkey.Name">
48+
select name_fred as generatedName from table2 where id = #{nameId}
49+
</selectKey>
50+
update table2 set name = #{name} where id = #{nameId}
51+
</update>
52+
53+
<update id="updateTable2WithGeneratedKeyXml" useGeneratedKeys="true" keyProperty="generatedName" keyColumn="NAME_FRED">
54+
update table2 set name = #{name} where id = #{nameId}
55+
</update>
56+
</mapper>

0 commit comments

Comments
 (0)