Package org.apache.ibatis.session

Examples of org.apache.ibatis.session.SqlSession.clearCache()


      b.setId(2);
      b.setName("222");
      sqlSession.insert("insertUser", b);
      List<BatchResult> batchResults = sqlSession.flushStatements();
      batchResults.clear();
      sqlSession.clearCache();
      sqlSession.commit();
      List<User> users = sqlSession.selectList("selectUser");
      assertEquals(2, users.size());
    } finally {
      sqlSession.close();
View Full Code Here


      assertEquals(1, mapperProxyFactory.getMethodCache().size());
      assertTrue(mapperProxyFactory.getMethodCache().containsKey(selectBlog));
      final MapperMethod cachedSelectBlog = mapperProxyFactory.getMethodCache().get(selectBlog);

      // Call mapper method again and verify the cache is unchanged:
      session.clearCache();
      mapper.selectBlog(1);
      assertEquals(1, mapperProxyFactory.getMethodCache().size());
      assertSame(cachedSelectBlog, mapperProxyFactory.getMethodCache().get(selectBlog));

      // Call another mapper method and verify that it shows up in the cache as well:
View Full Code Here

      mapper.selectBlog(1);
      assertEquals(1, mapperProxyFactory.getMethodCache().size());
      assertSame(cachedSelectBlog, mapperProxyFactory.getMethodCache().get(selectBlog));

      // Call another mapper method and verify that it shows up in the cache as well:
      session.clearCache();
      mapper.selectBlogByIdUsingConstructor(1);
      assertEquals(2, mapperProxyFactory.getMethodCache().size());
      assertSame(cachedSelectBlog, mapperProxyFactory.getMethodCache().get(selectBlog));
      assertTrue(mapperProxyFactory.getMethodCache().containsKey(selectBlogByIdUsingConstructor));
View Full Code Here

  @Override
  public void clearCache() {
    for (Shard shard : this.getShards()) {
      SqlSession session = shard.establishSqlSession();
      if (session != null) {
        session.clearCache();
      }
    }
  }

  @Override
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.