|
| 1 | +/** |
| 2 | + * Copyright 2009-2019 the original author or authors. |
| 3 | + * <p> |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * <p> |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * <p> |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | +package org.apache.ibatis.submitted.selectkey; |
| 17 | + |
| 18 | +import org.apache.ibatis.annotations.*; |
| 19 | + |
| 20 | +import java.util.Map; |
| 21 | + |
| 22 | +public interface AnnotatedMapper { |
| 23 | + |
| 24 | + @Insert("insert into table2 (name) values(#{name})") |
| 25 | + @SelectKey(statement = "call identity()", keyProperty = "nameId", before = false, resultType = int.class) |
| 26 | + int insertTable2(Name name); |
| 27 | + |
| 28 | + @Insert("insert into table2 (name) values(#{name})") |
| 29 | + @Options(useGeneratedKeys = true, keyProperty = "nameId,generatedName", keyColumn = "ID,NAME_FRED") |
| 30 | + int insertTable2WithGeneratedKey(Name name); |
| 31 | + |
| 32 | + int insertTable2WithGeneratedKeyXml(Name name); |
| 33 | + |
| 34 | + @Insert("insert into table2 (name) values(#{name})") |
| 35 | + @SelectKey(statement = "select id, name_fred from table2 where id = identity()", keyProperty = "nameId,generatedName", keyColumn = "ID,NAME_FRED", before = false, resultType = Map.class) |
| 36 | + int insertTable2WithSelectKeyWithKeyMap(Name name); |
| 37 | + |
| 38 | + int insertTable2WithSelectKeyWithKeyMapXml(Name name); |
| 39 | + |
| 40 | + @Insert("insert into table2 (name) values(#{name})") |
| 41 | + @SelectKey(statement = "select id as nameId, name_fred as generatedName from table2 where id = identity()", keyProperty = "nameId,generatedName", before = false, resultType = Name.class) |
| 42 | + int insertTable2WithSelectKeyWithKeyObject(Name name); |
| 43 | + |
| 44 | + int insertTable2WithSelectKeyWithKeyObjectXml(Name name); |
| 45 | + |
| 46 | + @Insert("insert into table3 (id, name) values(#{nameId}, #{name})") |
| 47 | + @SelectKey(statement = "call next value for TestSequence", keyProperty = "nameId", before = true, resultType = int.class) |
| 48 | + int insertTable3(Name name); |
| 49 | + |
| 50 | + @InsertProvider(type = SqlProvider.class, method = "insertTable3_2") |
| 51 | + @SelectKey(statement = "call next value for TestSequence", keyProperty = "nameId", before = true, resultType = int.class) |
| 52 | + int insertTable3_2(Name name); |
| 53 | + |
| 54 | + @Update("update table2 set name = #{name} where id = #{nameId}") |
| 55 | + @Options(useGeneratedKeys = true, keyProperty = "generatedName") |
| 56 | + int updateTable2WithGeneratedKey(Name name); |
| 57 | + |
| 58 | + int updateTable2WithGeneratedKeyXml(Name name); |
| 59 | + |
| 60 | + @Update("update table2 set name = #{name} where id = #{nameId}") |
| 61 | + @SelectKey(statement = "select name_fred from table2 where id = #{nameId}", keyProperty = "generatedName", keyColumn = "NAME_FRED", before = false, resultType = String.class) |
| 62 | + int updateTable2WithSelectKeyWithKeyMap(Name name); |
| 63 | + |
| 64 | + int updateTable2WithSelectKeyWithKeyMapXml(Name name); |
| 65 | + |
| 66 | + @Update("update table2 set name = #{name} where id = #{nameId}") |
| 67 | + @SelectKey(statement = "select name_fred as generatedName from table2 where id = #{nameId}", keyProperty = "generatedName", before = false, resultType = Name.class) |
| 68 | + int updateTable2WithSelectKeyWithKeyObject(Name name); |
| 69 | + |
| 70 | + int updateTable2WithSelectKeyWithKeyObjectXml(Name name); |
| 71 | +} |
0 commit comments