Ibatis SelectKey
1 # <!-- Oracle SEQUENCE Example using .NET 1.1 System.Data.OracleClient -->
2 # <insert id="insertProduct-ORACLE" parameterClass="product">
3 # <selectKey resultClass="int" type="pre" keyProperty="id" >
4 # SELECT STOCKIDSEQUENCE.NEXTVAL AS VALUE FROM DUAL
5 # </selectKey>
6 # insert into PRODUCT (PRD_ID,PRD_DESCRIPTION) values (#id#,#description#)
7 # </insert>
8 #
9 # <!-- Microsoft SQL Server IDENTITY Column Example -->
10 # <insert id="insertProduct-MS-SQL" parameterClass="product">
11 # insert into PRODUCT (PRD_DESCRIPTION)
12 # values (#description#)
13 # <selectKey resultClass="int" type="post" keyProperty="id" >
14 # select @@IDENTITY as value
15 # </selectKey>
16 # </insert>
17 #
18 # <!-- MySQL Example -->
19 # <insert id="insertProduct-MYSQL" parameterClass="product">
20 # insert into PRODUCT (PRD_DESCRIPTION)
21 # values (#description#)
22 # <selectKey resultClass="int" type="post" keyProperty="id" >
23 # select LAST_INSERT_ID() as value
24 # </selectKey>
25 # </insert>
26
2 # <insert id="insertProduct-ORACLE" parameterClass="product">
3 # <selectKey resultClass="int" type="pre" keyProperty="id" >
4 # SELECT STOCKIDSEQUENCE.NEXTVAL AS VALUE FROM DUAL
5 # </selectKey>
6 # insert into PRODUCT (PRD_ID,PRD_DESCRIPTION) values (#id#,#description#)
7 # </insert>
8 #
9 # <!-- Microsoft SQL Server IDENTITY Column Example -->
10 # <insert id="insertProduct-MS-SQL" parameterClass="product">
11 # insert into PRODUCT (PRD_DESCRIPTION)
12 # values (#description#)
13 # <selectKey resultClass="int" type="post" keyProperty="id" >
14 # select @@IDENTITY as value
15 # </selectKey>
16 # </insert>
17 #
18 # <!-- MySQL Example -->
19 # <insert id="insertProduct-MYSQL" parameterClass="product">
20 # insert into PRODUCT (PRD_DESCRIPTION)
21 # values (#description#)
22 # <selectKey resultClass="int" type="post" keyProperty="id" >
23 # select LAST_INSERT_ID() as value
24 # </selectKey>
25 # </insert>
26