View Javadoc
1   /*
2    *    Copyright 2009-2021 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    *       http://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},", "#{sum,jdbcType=INTEGER,mode=OUT})}" })
54    @Options(statementType = StatementType.CALLABLE)
55    Object adderAsSelectAnnotated(Parameter parameter);
56  
57    @Update({ "{call sptest.adder(", "#{addend1,jdbcType=INTEGER,mode=IN},", "#{addend2,jdbcType=INTEGER,mode=IN},", "#{sum,jdbcType=INTEGER,mode=OUT})}" })
58    @Options(statementType = StatementType.CALLABLE)
59    void adderAsUpdateAnnotated(Parameter parameter);
60  
61    @Select("{call sptest.getname(#{id,jdbcType=INTEGER,mode=IN})}")
62    @Results({ @Result(column = "ID", property = "id"), @Result(column = "FIRST_NAME", property = "firstName"), @Result(column = "LAST_NAME", property = "lastName") })
63    @Options(statementType = StatementType.CALLABLE)
64    Name getNameAnnotated(Integer id);
65  
66    @Select("{call sptest.getname(#{id,jdbcType=INTEGER,mode=IN})}")
67    @ResultMap("nameResult")
68    @Options(statementType = StatementType.CALLABLE)
69    Name getNameAnnotatedWithXMLResultMap(Integer id);
70  
71    @Select({ "{call sptest.getnames(", "#{lowestId,jdbcType=INTEGER,mode=IN},", "#{totalRows,jdbcType=INTEGER,mode=OUT})}" })
72    @Results({ @Result(column = "ID", property = "id"), @Result(column = "FIRST_NAME", property = "firstName"), @Result(column = "LAST_NAME", property = "lastName") })
73    @Options(statementType = StatementType.CALLABLE)
74    List<Name> getNamesAnnotated(Map<String, Object> parms);
75  
76    @Select({ "{call sptest.getnames(", "#{lowestId,jdbcType=INTEGER,mode=IN},", "#{totalRows,jdbcType=INTEGER,mode=OUT})}" })
77    @ResultMap("nameResult")
78    @Options(statementType = StatementType.CALLABLE)
79    List<Name> getNamesAnnotatedWithXMLResultMap(Map<String, Object> parms);
80  
81    @Select({ "{call sptest.getnamesLowHigh(", "#{lowestId,jdbcType=INTEGER,mode=IN},", "#{highestId,jdbcType=INTEGER,mode=IN})}" })
82    @ResultMap("nameResult")
83    @Options(statementType = StatementType.CALLABLE)
84    List<Name> getNamesAnnotatedLowHighWithXMLResultMap(@Param("lowestId") int lowestId, @Param("highestId") int highestId);
85  
86    @Select({ "{call sptest.arraytest(", "#{ids,mode=IN,jdbcType=ARRAY},", "#{requestedRows,jdbcType=INTEGER,mode=OUT},", "#{returnedIds,mode=OUT,jdbcType=ARRAY})}" })
87    @Results({ @Result(column = "ID", property = "id"), @Result(column = "FIRST_NAME", property = "firstName"), @Result(column = "LAST_NAME", property = "lastName") })
88    @Options(statementType = StatementType.CALLABLE)
89    List<Name> getNamesWithArrayAnnotated(Map<String, Object> parms);
90  
91    @Select({ "{call sptest.arraytest(", "#{ids,mode=IN,jdbcType=ARRAY},", "#{requestedRows,jdbcType=INTEGER,mode=OUT},", "#{returnedIds,mode=OUT,jdbcType=ARRAY})}" })
92    @ResultMap("nameResult")
93    @Options(statementType = StatementType.CALLABLE)
94    List<Name> getNamesWithArrayAnnotatedWithXMLResultMap(Map<String, Object> parms);
95  
96    @Select("{call sptest.getnamesanditems()}")
97    @ResultMap("nameResult,itemResult")
98    @Options(statementType = StatementType.CALLABLE)
99    List<List<?>> getNamesAndItemsAnnotatedWithXMLResultMap();
100 
101   @Select("{call sptest.getnamesanditems()}")
102   @ResultMap({ "nameResult", "itemResult" })
103   @Options(statementType = StatementType.CALLABLE)
104   List<List<?>> getNamesAndItemsAnnotatedWithXMLResultMapArray();
105 
106   List<Book> getBookAndGenre();
107 }