Skip to content

Commit 469e021

Browse files
committed
Change the stored procedure example code to show when to clear the session cache
1 parent f66de16 commit 469e021

File tree

1 file changed

+11
-7
lines changed
  • src/test/java/org/apache/ibatis/submitted/sptests

1 file changed

+11
-7
lines changed

src/test/java/org/apache/ibatis/submitted/sptests/SPTest.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,12 @@ public void testAdderAsSelect() {
8080
* in a stored procedure.
8181
* This procedure does not return a result set.
8282
*
83-
* Currently this test will fail because of a MyBatis cache issue.
83+
* Currently this test will fail without clearing the cache because
84+
* of a MyBatis cache issue.
8485
*
8586
* This test shows using a multi-property parameter.
8687
*/
8788
@Test
88-
@Ignore("until MyBatis cache issue fixed")
8989
public void testAdderAsSelectDoubleCall1() {
9090
SqlSession sqlSession = sqlSessionFactory.openSession();
9191
try {
@@ -98,8 +98,9 @@ public void testAdderAsSelectDoubleCall1() {
9898
spMapper.adder(parameter);
9999
assertEquals((Integer) 5, parameter.getSum());
100100

101-
// this fails because there are two calls to the same SP with the same
102-
// parms in the same session.
101+
// clear cache is required in this instance.
102+
sqlSession.clearCache();
103+
103104
parameter = new Parameter();
104105
parameter.setAddend1(2);
105106
parameter.setAddend2(3);
@@ -259,10 +260,11 @@ public void testCallWithResultSet3() {
259260
*
260261
* This test shows using a Map parameter.
261262
*
262-
* The cache problem is in effect with this test.
263+
* Currently this test will fail without clearing the cache because
264+
* of a MyBatis cache issue.
263265
*/
264266
@Test
265-
@Ignore("until hsqldb 2.0.1 is released, and MyBatis cache issue fixed")
267+
@Ignore("until hsqldb 2.0.1 is released")
266268
public void testCallWithResultSet4() {
267269
SqlSession sqlSession = sqlSessionFactory.openSession();
268270
try {
@@ -274,11 +276,13 @@ public void testCallWithResultSet4() {
274276
assertEquals(2, parms.get("totalRows"));
275277
assertEquals(2, names.size());
276278

279+
// clear cache is required in this instance.
280+
sqlSession.clearCache();
281+
277282
parms = new HashMap<String, Object>();
278283
parms.put("lowestId", 2);
279284
names = spMapper.getNames(parms);
280285
assertEquals(2, names.size());
281-
// fails because of cache problem
282286
assertEquals(2, parms.get("totalRows"));
283287
} finally {
284288
sqlSession.close();

0 commit comments

Comments
 (0)