List of usage examples for org.apache.ibatis.session SqlSession close
@Override
void close();
From source file:com.quancheng.mybatis.mapper.test.country.TestSelectCount.java
License:Open Source License
/** * ??/*from w w w . ja v a2 s . co m*/ */ @Test public void testDynamicSelect() { SqlSession sqlSession = MybatisHelper.getSqlSession(); try { CountryMapper mapper = sqlSession.getMapper(CountryMapper.class); Country country = new Country(); country.setCountrycode("CN"); Assert.assertEquals(1, mapper.selectCount(country)); } finally { sqlSession.close(); } }
From source file:com.quancheng.mybatis.mapper.test.country.TestSelectCount.java
License:Open Source License
/** * ?//from w w w . java2s . c o m */ @Test public void testDynamicSelectZero() { SqlSession sqlSession = MybatisHelper.getSqlSession(); try { CountryMapper mapper = sqlSession.getMapper(CountryMapper.class); Country country = new Country(); country.setCountrycode("CN"); country.setCountryname("?");// China Assert.assertEquals(0, mapper.selectCount(country)); } finally { sqlSession.close(); } }
From source file:com.quancheng.mybatis.mapper.test.country.TestSelectOne.java
License:Open Source License
/** * //from w w w . j ava 2s. c o m */ @Test(expected = TooManyResultsException.class) public void testDynamicSelectAll() { SqlSession sqlSession = MybatisHelper.getSqlSession(); try { CountryMapper mapper = sqlSession.getMapper(CountryMapper.class); Country country = mapper.selectOne(new Country()); } finally { sqlSession.close(); } }
From source file:com.quancheng.mybatis.mapper.test.country.TestSelectOne.java
License:Open Source License
/** * ?null// ww w . ja v a2 s. co m */ @Test(expected = TooManyResultsException.class) public void testDynamicSelectAllByNull() { SqlSession sqlSession = MybatisHelper.getSqlSession(); try { CountryMapper mapper = sqlSession.getMapper(CountryMapper.class); mapper.selectOne(null); } finally { sqlSession.close(); } }
From source file:com.quancheng.mybatis.mapper.test.country.TestSelectOne.java
License:Open Source License
/** * ??/* w w w.jav a 2s . c o m*/ */ @Test public void testDynamicSelect() { SqlSession sqlSession = MybatisHelper.getSqlSession(); try { CountryMapper mapper = sqlSession.getMapper(CountryMapper.class); Country country = new Country(); country.setCountrycode("CN"); Country result = mapper.selectOne(country); Assert.assertEquals(true, result.getId() == 35); Assert.assertEquals("China", result.getCountryname()); } finally { sqlSession.close(); } }
From source file:com.quancheng.mybatis.mapper.test.country.TestSelectOne.java
License:Open Source License
/** * ?/*from www . j a v a2 s .co m*/ */ @Test public void testDynamicSelectZero() { SqlSession sqlSession = MybatisHelper.getSqlSession(); try { CountryMapper mapper = sqlSession.getMapper(CountryMapper.class); Country country = new Country(); country.setCountrycode("CN"); country.setCountryname("?");// China Country result = mapper.selectOne(country); Assert.assertNull(result); } finally { sqlSession.close(); } }
From source file:com.quancheng.mybatis.mapper.test.country.TestUpdateByPrimaryKey.java
License:Open Source License
/** * 0// w ww . j ava 2 s . co m */ @Test public void testDynamicUpdateByPrimaryKeyAll() { SqlSession sqlSession = MybatisHelper.getSqlSession(); try { CountryMapper mapper = sqlSession.getMapper(CountryMapper.class); Assert.assertEquals(0, mapper.updateByPrimaryKey(new Country())); } finally { sqlSession.close(); } }
From source file:com.quancheng.mybatis.mapper.test.country.TestUpdateByPrimaryKey.java
License:Open Source License
/** * ?null//from w w w. ja v a2 s .c om */ @Test public void testDynamicUpdateByPrimaryKeyAllByNull() { SqlSession sqlSession = MybatisHelper.getSqlSession(); try { CountryMapper mapper = sqlSession.getMapper(CountryMapper.class); mapper.updateByPrimaryKey(null); } finally { sqlSession.close(); } }
From source file:com.quancheng.mybatis.mapper.test.country.TestUpdateByPrimaryKey.java
License:Open Source License
/** * ??/* w w w .ja va 2s . c o m*/ */ @Test public void testDynamicUpdateByPrimaryKey() { SqlSession sqlSession = MybatisHelper.getSqlSession(); try { CountryMapper mapper = sqlSession.getMapper(CountryMapper.class); Country country = new Country(); country.setId(174); country.setCountryname(null); country.setCountryname(""); Assert.assertEquals(1, mapper.updateByPrimaryKey(country)); country = mapper.selectByPrimaryKey(174); Assert.assertNotNull(country); Assert.assertEquals(174, (int) country.getId()); Assert.assertEquals("", country.getCountryname()); Assert.assertNull(country.getCountrycode()); } finally { sqlSession.close(); } }