View Javadoc
1   /*
2    *    Copyright 2009-2023 the original author or authors.
3    *
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    *
8    *       https://www.apache.org/licenses/LICENSE-2.0
9    *
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.sptests;
17  
18  import java.util.List;
19  import java.util.Map;
20  
21  import org.apache.ibatis.annotations.Options;
22  import org.apache.ibatis.annotations.Param;
23  import org.apache.ibatis.annotations.Result;
24  import org.apache.ibatis.annotations.ResultMap;
25  import org.apache.ibatis.annotations.Results;
26  import org.apache.ibatis.annotations.Select;
27  import org.apache.ibatis.annotations.Update;
28  import org.apache.ibatis.mapping.StatementType;
29  
30  public interface SPMapper {
31    // XML based
32    Object adderAsSelect(Parameter parameter);
33  
34    void adderAsUpdate(Parameter parameter);
35  
36    void adderWithParameterMap(Map<String, Object> parameter);
37  
38    Name getName(Integer id);
39  
40    List<Name> getNames(Map<String, Object> parms);
41  
42    List<Name> getNamesWithArray(Map<String, Object> parms);
43  
44    List<List<?>> getNamesAndItems();
45  
46    List<Name> getNamesAndItemsLinked();
47  
48    List<Name> getNamesAndItemsLinkedById(int id);
49  
50    Object echoDate(Map<String, Object> parameter); // issue #145
51  
52    // annotated
53    @Select({ "{call sptest.adder(", "#{addend1,jdbcType=INTEGER,mode=IN},", "#{addend2,jdbcType=INTEGER,mode=IN},",
54        "#{sum,jdbcType=INTEGER,mode=OUT})}" })
55    @Options(statementType = StatementType.CALLABLE)
56    Object adderAsSelectAnnotated(Parameter parameter);
57  
58    @Update({ "{call sptest.adder(", "#{addend1,jdbcType=INTEGER,mode=IN},", "#{addend2,jdbcType=INTEGER,mode=IN},",
59        "#{sum,jdbcType=INTEGER,mode=OUT})}" })
60    @Options(statementType = StatementType.CALLABLE)
61    void adderAsUpdateAnnotated(Parameter parameter);
62  
63    @Select("{call sptest.getname(#{id,jdbcType=INTEGER,mode=IN})}")
64    @Results({ @Result(column = "ID", property = "id"), @Result(column = "FIRST_NAME", property = "firstName"),
65        @Result(column = "LAST_NAME", property = "lastName") })
66    @Options(statementType = StatementType.CALLABLE)
67    Name getNameAnnotated(Integer id);
68  
69    @Select("{call sptest.getname(#{id,jdbcType=INTEGER,mode=IN})}")
70    @ResultMap("nameResult")
71    @Options(statementType = StatementType.CALLABLE)
72    Name getNameAnnotatedWithXMLResultMap(Integer id);
73  
74    @Select({ "{call sptest.getnames(", "#{lowestId,jdbcType=INTEGER,mode=IN},",
75        "#{totalRows,jdbcType=INTEGER,mode=OUT})}" })
76    @Results({ @Result(column = "ID", property = "id"), @Result(column = "FIRST_NAME", property = "firstName"),
77        @Result(column = "LAST_NAME", property = "lastName") })
78    @Options(statementType = StatementType.CALLABLE)
79    List<Name> getNamesAnnotated(Map<String, Object> parms);
80  
81    @Select({ "{call sptest.getnames(", "#{lowestId,jdbcType=INTEGER,mode=IN},",
82        "#{totalRows,jdbcType=INTEGER,mode=OUT})}" })
83    @ResultMap("nameResult")
84    @Options(statementType = StatementType.CALLABLE)
85    List<Name> getNamesAnnotatedWithXMLResultMap(Map<String, Object> parms);
86  
87    @Select({ "{call sptest.getnamesLowHigh(", "#{lowestId,jdbcType=INTEGER,mode=IN},",
88        "#{highestId,jdbcType=INTEGER,mode=IN})}" })
89    @ResultMap("nameResult")
90    @Options(statementType = StatementType.CALLABLE)
91    List<Name> getNamesAnnotatedLowHighWithXMLResultMap(@Param("lowestId") int lowestId,
92        @Param("highestId") int highestId);
93  
94    @Select({ "{call sptest.arraytest(", "#{ids,mode=IN,jdbcType=ARRAY},", "#{requestedRows,jdbcType=INTEGER,mode=OUT},",
95        "#{returnedIds,mode=OUT,jdbcType=ARRAY})}" })
96    @Results({ @Result(column = "ID", property = "id"), @Result(column = "FIRST_NAME", property = "firstName"),
97        @Result(column = "LAST_NAME", property = "lastName") })
98    @Options(statementType = StatementType.CALLABLE)
99    List<Name> getNamesWithArrayAnnotated(Map<String, Object> parms);
100 
101   @Select({ "{call sptest.arraytest(", "#{ids,mode=IN,jdbcType=ARRAY},", "#{requestedRows,jdbcType=INTEGER,mode=OUT},",
102       "#{returnedIds,mode=OUT,jdbcType=ARRAY})}" })
103   @ResultMap("nameResult")
104   @Options(statementType = StatementType.CALLABLE)
105   List<Name> getNamesWithArrayAnnotatedWithXMLResultMap(Map<String, Object> parms);
106 
107   @Select("{call sptest.getnamesanditems()}")
108   @ResultMap("nameResult,itemResult")
109   @Options(statementType = StatementType.CALLABLE)
110   List<List<?>> getNamesAndItemsAnnotatedWithXMLResultMap();
111 
112   @Select("{call sptest.getnamesanditems()}")
113   @ResultMap({ "nameResult", "itemResult" })
114   @Options(statementType = StatementType.CALLABLE)
115   List<List<?>> getNamesAndItemsAnnotatedWithXMLResultMapArray();
116 
117   List<Book> getBookAndGenre();
118 }