Example usage for org.apache.ibatis.session SqlSessionManager openSession

List of usage examples for org.apache.ibatis.session SqlSessionManager openSession

Introduction

In this page you can find the example usage for org.apache.ibatis.session SqlSessionManager openSession.

Prototype

@Override
    public SqlSession openSession() 

Source Link

Usage

From source file:cn.com.bricks.mybatis.rbac.DynamicRbacInterceptorNGTest.java

/**
 * intercept (DynamicRbacInterceptor)//from ww w.jav  a  2 s.c o m
 */
@Test
public void testIntercept() throws Throwable {
    System.out.println("intercept");
    InputStream inputStream = null;
    try {

        inputStream = Resources.getResourceAsStream("cn/com/bricks/mybatis/test/MapperConfig.xml");
        SqlSessionManager sqlSession = SqlSessionManager.newInstance(inputStream);

        int count = sqlSession.openSession()
                .selectOne("org.apache.ibatis.domain.blog.mappers.BlogMapper.selectCountOfPosts");
        System.out.println(count);
    } catch (IOException ex) {
        Logger.getLogger(DynamicRbacInterceptorNGTest.class.getName()).log(Level.SEVERE, null, ex);
    } finally {
        try {
            inputStream.close();
        } catch (IOException ex) {
            Logger.getLogger(DynamicRbacInterceptorNGTest.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

From source file:org.mybatis.guice.session.SqlSessionManagerProviderTest.java

License:Apache License

@Test
public void get() {
    SqlSessionManager sqlSessionManager = sqlSessionManagerProvider.get();

    assertNotNull(sqlSessionManager);// ww  w.j  a  v  a  2 s  .c o  m
    sqlSessionManager.openSession();
    verify(sqlSessionFactory).openSession();
}