1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.ibatis.binding;
17
18 import java.util.List;
19
20 import org.apache.ibatis.annotations.Arg;
21 import org.apache.ibatis.annotations.CacheNamespace;
22 import org.apache.ibatis.annotations.ConstructorArgs;
23 import org.apache.ibatis.annotations.Flush;
24 import org.apache.ibatis.annotations.Param;
25 import org.apache.ibatis.annotations.Result;
26 import org.apache.ibatis.annotations.Results;
27 import org.apache.ibatis.annotations.Select;
28 import org.apache.ibatis.domain.blog.Author;
29 import org.apache.ibatis.domain.blog.Post;
30 import org.apache.ibatis.domain.blog.Section;
31 import org.apache.ibatis.executor.BatchResult;
32 import org.apache.ibatis.session.RowBounds;
33
34 @CacheNamespace(readWrite = false)
35 public interface BoundAuthorMapper {
36
37
38
39 List<Post> findPostsInArray(Integer[] ids);
40
41
42
43 List<Post> findPostsInList(List<Integer> ids);
44
45
46
47 int insertAuthor(Author author);
48
49 int insertAuthorInvalidSelectKey(Author author);
50
51 int insertAuthorInvalidInsert(Author author);
52
53 int insertAuthorDynamic(Author author);
54
55
56
57 @ConstructorArgs({ @Arg(column = "AUTHOR_ID", javaType = int.class) })
58
59 @Results({
60 @Result(property = "username", column = "AUTHOR_USERNAME"),
61 @Result(property = "password", column = "AUTHOR_PASSWORD"),
62 @Result(property = "email", column = "AUTHOR_EMAIL"),
63 @Result(property = "bio", column = "AUTHOR_BIO")
64 })
65 @Select({
66 "SELECT ",
67 " ID as AUTHOR_ID,",
68 " USERNAME as AUTHOR_USERNAME,",
69 " PASSWORD as AUTHOR_PASSWORD,",
70 " EMAIL as AUTHOR_EMAIL,",
71 " BIO as AUTHOR_BIO",
72 "FROM AUTHOR WHERE ID = #{id}"})
73
74 Author selectAuthor(int id);
75
76
77
78 @Result(property = "id", column = "AUTHOR_ID", id = true)
79 @Result(property = "username", column = "AUTHOR_USERNAME")
80 @Result(property = "password", column = "AUTHOR_PASSWORD")
81 @Result(property = "email", column = "AUTHOR_EMAIL")
82 @Result(property = "bio", column = "AUTHOR_BIO")
83
84 @Select({
85 "SELECT ",
86 " ID as AUTHOR_ID,",
87 " USERNAME as AUTHOR_USERNAME,",
88 " PASSWORD as AUTHOR_PASSWORD,",
89 " EMAIL as AUTHOR_EMAIL,",
90 " BIO as AUTHOR_BIO",
91 "FROM AUTHOR WHERE ID = #{id}"})
92
93 Author selectAuthorMapToPropertiesUsingRepeatable(int id);
94
95
96
97
98 @ConstructorArgs({
99 @Arg(column = "AUTHOR_ID", javaType = Integer.class),
100 @Arg(column = "AUTHOR_USERNAME", javaType = String.class),
101 @Arg(column = "AUTHOR_PASSWORD", javaType = String.class),
102 @Arg(column = "AUTHOR_EMAIL", javaType = String.class),
103 @Arg(column = "AUTHOR_BIO", javaType = String.class),
104 @Arg(column = "AUTHOR_SECTION", javaType = Section.class)
105 })
106 @Select({
107 "SELECT ",
108 " ID as AUTHOR_ID,",
109 " USERNAME as AUTHOR_USERNAME,",
110 " PASSWORD as AUTHOR_PASSWORD,",
111 " EMAIL as AUTHOR_EMAIL,",
112 " BIO as AUTHOR_BIO,",
113 " FAVOURITE_SECTION as AUTHOR_SECTION",
114 "FROM AUTHOR WHERE ID = #{id}"})
115
116 Author selectAuthorConstructor(int id);
117
118
119
120 @Arg(column = "AUTHOR_ID", javaType = Integer.class, id = true)
121 @Arg(column = "AUTHOR_USERNAME", javaType = String.class)
122 @Arg(column = "AUTHOR_PASSWORD", javaType = String.class)
123 @Arg(column = "AUTHOR_EMAIL", javaType = String.class)
124 @Arg(column = "AUTHOR_BIO", javaType = String.class)
125 @Arg(column = "AUTHOR_SECTION", javaType = Section.class)
126
127 @Select({
128 "SELECT ",
129 " ID as AUTHOR_ID,",
130 " USERNAME as AUTHOR_USERNAME,",
131 " PASSWORD as AUTHOR_PASSWORD,",
132 " EMAIL as AUTHOR_EMAIL,",
133 " BIO as AUTHOR_BIO,",
134 " FAVOURITE_SECTION as AUTHOR_SECTION",
135 "FROM AUTHOR WHERE ID = #{id}"})
136
137 Author selectAuthorMapToConstructorUsingRepeatable(int id);
138
139
140
141 @Arg(column = "AUTHOR_ID", javaType = int.class)
142 @Result(property = "username", column = "AUTHOR_USERNAME")
143
144 @Select({
145 "SELECT ",
146 " ID as AUTHOR_ID,",
147 " USERNAME as AUTHOR_USERNAME,",
148 " PASSWORD as AUTHOR_PASSWORD,",
149 " EMAIL as AUTHOR_EMAIL,",
150 " BIO as AUTHOR_BIO",
151 "FROM AUTHOR WHERE ID = #{id}"})
152
153 Author selectAuthorUsingSingleRepeatable(int id);
154
155
156
157
158 @ConstructorArgs({
159 @Arg(column = "AUTHOR_ID", javaType = Integer.class),
160 @Arg(column = "AUTHOR_USERNAME", javaType = String.class),
161 @Arg(column = "AUTHOR_PASSWORD", javaType = String.class),
162 @Arg(column = "AUTHOR_EMAIL", javaType = String.class),
163 @Arg(column = "AUTHOR_BIO", javaType = String.class)
164 })
165 @Arg(column = "AUTHOR_SECTION", javaType = Section.class)
166 @Select({
167 "SELECT ",
168 " ID as AUTHOR_ID,",
169 " USERNAME as AUTHOR_USERNAME,",
170 " PASSWORD as AUTHOR_PASSWORD,",
171 " EMAIL as AUTHOR_EMAIL,",
172 " BIO as AUTHOR_BIO,",
173 " FAVOURITE_SECTION as AUTHOR_SECTION",
174 "FROM AUTHOR WHERE ID = #{id}"})
175
176 Author selectAuthorUsingBothArgAndConstructorArgs(int id);
177
178
179
180 @Results(@Result(property = "id", column = "AUTHOR_ID"))
181 @Result(property = "username", column = "AUTHOR_USERNAME")
182
183 @Select({
184 "SELECT ",
185 " ID as AUTHOR_ID,",
186 " USERNAME as AUTHOR_USERNAME",
187 "FROM AUTHOR WHERE ID = #{id}"})
188
189 Author selectAuthorUsingBothResultAndResults(int id);
190
191
192
193 List<Post> findThreeSpecificPosts(@Param("one") int one, RowBounds rowBounds, @Param("two") int two, int three);
194
195 @Flush
196 List<BatchResult> flush();
197
198 }