@@ -82,9 +82,6 @@ public void testAdderAsSelect() {
82
82
* in a stored procedure.
83
83
* This procedure does not return a result set.
84
84
*
85
- * Currently this test will fail without clearing the cache because
86
- * of a MyBatis cache issue.
87
- *
88
85
* This test shows using a multi-property parameter.
89
86
*/
90
87
@ Test
@@ -100,9 +97,6 @@ public void testAdderAsSelectDoubleCall1() {
100
97
spMapper .adder (parameter );
101
98
assertEquals ((Integer ) 5 , parameter .getSum ());
102
99
103
- // Resolved Output Parameter Caching Issue for Callable statements
104
- // sqlSession.clearCache();
105
-
106
100
parameter = new Parameter ();
107
101
parameter .setAddend1 (2 );
108
102
parameter .setAddend2 (3 );
@@ -119,10 +113,10 @@ public void testAdderAsSelectDoubleCall1() {
119
113
* in a stored procedure.
120
114
* This procedure does not return a result set.
121
115
*
122
- * This test shows using a multi-property parameter.
116
+ * This test also demonstrates session level cache for
117
+ * output parameters.
123
118
*
124
- * This test shows that the cache problem does not manifest if
125
- * the input parameters are different.
119
+ * This test shows using a multi-property parameter.
126
120
*/
127
121
@ Test
128
122
public void testAdderAsSelectDoubleCall2 () {
@@ -149,8 +143,7 @@ public void testAdderAsSelectDoubleCall2() {
149
143
}
150
144
151
145
/**
152
- * This test shows that the cache problem is not in effect if
153
- * stored procedures with out parms are defined as <update> rather
146
+ * This test shows how to call a stored procedure defined as <update> rather
154
147
* then <select>. Of course, this only works if you are not returning
155
148
* a result set.
156
149
*
@@ -180,6 +173,36 @@ public void testAdderAsUpdate() {
180
173
}
181
174
}
182
175
176
+ /**
177
+ * This test shows the use of a declared parameter map.
178
+ * We generally prefer inline parameters, because the syntax
179
+ * is more intuitive (no pesky question marks), but a parameter map
180
+ * will work.
181
+ */
182
+ @ Test
183
+ public void testAdderAsUpdateWithParameterMap () {
184
+ SqlSession sqlSession = sqlSessionFactory .openSession ();
185
+ try {
186
+ Map <String , Object > parms = new HashMap <String , Object >();
187
+ parms .put ("addend1" , 3 );
188
+ parms .put ("addend2" , 4 );
189
+
190
+ SPMapper spMapper = sqlSession .getMapper (SPMapper .class );
191
+
192
+ spMapper .adder3 (parms );
193
+ assertEquals (7 , parms .get ("sum" ));
194
+
195
+ parms = new HashMap <String , Object >();
196
+ parms .put ("addend1" , 2 );
197
+ parms .put ("addend2" , 3 );
198
+ spMapper .adder3 (parms );
199
+ assertEquals (5 , parms .get ("sum" ));
200
+
201
+ } finally {
202
+ sqlSession .close ();
203
+ }
204
+ }
205
+
183
206
/**
184
207
* This test shows how to use an input parameter and return a result
185
208
* set from a stored procedure.
@@ -229,9 +252,6 @@ public void testCallWithResultSet2() {
229
252
* return a result set from a stored procedure.
230
253
*
231
254
* This test shows using a Map parameter.
232
- *
233
- * This test shows that the cache problem does not manifest if
234
- * the input parameters are different.
235
255
*/
236
256
@ Test
237
257
@ Ignore ("until hsqldb 2.0.1 is released" )
@@ -261,9 +281,6 @@ public void testCallWithResultSet3() {
261
281
* return a result set from a stored procedure.
262
282
*
263
283
* This test shows using a Map parameter.
264
- *
265
- * Currently this test will fail without clearing the cache because
266
- * of a MyBatis cache issue.
267
284
*/
268
285
@ Test
269
286
@ Ignore ("until hsqldb 2.0.1 is released" )
@@ -278,9 +295,6 @@ public void testCallWithResultSet4() {
278
295
assertEquals (2 , parms .get ("totalRows" ));
279
296
assertEquals (2 , names .size ());
280
297
281
- // Resolved Output Parameter Caching Issue for Callable statements
282
- // sqlSession.clearCache();
283
-
284
298
parms = new HashMap <String , Object >();
285
299
parms .put ("lowestId" , 2 );
286
300
names = spMapper .getNames (parms );
@@ -291,6 +305,12 @@ public void testCallWithResultSet4() {
291
305
}
292
306
}
293
307
308
+ /**
309
+ * This test shows how to use the ARRAY JDBC type
310
+ * with MyBatis.
311
+ *
312
+ * @throws SQLException
313
+ */
294
314
@ Test
295
315
@ Ignore ("until hsqldb 2.0.1 is released" )
296
316
public void testGetNamesWithArray () throws SQLException {
0 commit comments