List of usage examples for org.apache.ibatis.session SqlSession close
@Override
void close();
From source file:com.quancheng.mybatis.mapper.test.country.TestDeleteByPrimaryKey.java
License:Open Source License
/** * ?/*w w w. j ava2 s . c o m*/ */ @Test public void testDynamicDeleteZero() { SqlSession sqlSession = MybatisHelper.getSqlSession(); try { CountryMapper mapper = sqlSession.getMapper(CountryMapper.class); //? Assert.assertEquals(0, mapper.deleteByPrimaryKey(null)); Assert.assertEquals(0, mapper.deleteByPrimaryKey(-100)); Assert.assertEquals(0, mapper.deleteByPrimaryKey(0)); Assert.assertEquals(0, mapper.deleteByPrimaryKey(1000)); } finally { sqlSession.close(); } }
From source file:com.quancheng.mybatis.mapper.test.country.TestDeleteByPrimaryKey.java
License:Open Source License
/** * ???// w ww . j a va2s . co m */ @Test public void testDynamicDeleteEntity() { SqlSession sqlSession = MybatisHelper.getSqlSession(); try { CountryMapper mapper = sqlSession.getMapper(CountryMapper.class); Country country = new Country(); country.setId(100); Assert.assertEquals(1, mapper.deleteByPrimaryKey(country)); } finally { sqlSession.close(); } }
From source file:com.quancheng.mybatis.mapper.test.country.TestDeleteByPrimaryKey.java
License:Open Source License
/** * Map???// w ww. j ava2 s. com */ @Test public void testDynamicDeleteMap() { SqlSession sqlSession = MybatisHelper.getSqlSession(); try { CountryMapper mapper = sqlSession.getMapper(CountryMapper.class); Map map = new HashMap(); map.put("id", 100); Assert.assertEquals(1, mapper.deleteByPrimaryKey(map)); map = new HashMap(); map.put("countryname", "China"); Assert.assertEquals(0, mapper.deleteByPrimaryKey(map)); } finally { sqlSession.close(); } }
From source file:com.quancheng.mybatis.mapper.test.country.TestDeleteByPrimaryKey.java
License:Open Source License
/** * ??/*from www. j av a 2 s . c o m*/ */ @Test(expected = Exception.class) public void testDynamicDeleteNotFoundKeyProperties() { SqlSession sqlSession = MybatisHelper.getSqlSession(); try { CountryMapper mapper = sqlSession.getMapper(CountryMapper.class); //? Assert.assertEquals(0, mapper.deleteByPrimaryKey(new Key())); } finally { sqlSession.close(); } }
From source file:com.quancheng.mybatis.mapper.test.country.TestDeleteByPrimaryKey.java
License:Open Source License
/** * ?//from w w w. ja v a 2 s . c o m */ @Test public void testDynamicDeleteException() { SqlSession sqlSession = MybatisHelper.getSqlSession(); try { CountryMapper mapper = sqlSession.getMapper(CountryMapper.class); //? Assert.assertEquals(1, mapper.deleteByPrimaryKey(100)); } finally { sqlSession.rollback(); sqlSession.close(); } }
From source file:com.quancheng.mybatis.mapper.test.country.TestInsert.java
License:Open Source License
/** * ??,id?null,// w w w. java 2 s. c o m */ @Test(expected = PersistenceException.class) public void testDynamicInsertAll() { SqlSession sqlSession = MybatisHelper.getSqlSession(); try { CountryMapper mapper = sqlSession.getMapper(CountryMapper.class); mapper.insert(new Country()); } finally { sqlSession.close(); } }
From source file:com.quancheng.mybatis.mapper.test.country.TestInsert.java
License:Open Source License
/** * ??null//from w w w. j av a 2 s . c o m */ @Test(expected = PersistenceException.class) public void testDynamicInsertAllByNull() { SqlSession sqlSession = MybatisHelper.getSqlSession(); try { CountryMapper mapper = sqlSession.getMapper(CountryMapper.class); mapper.insert(null); } finally { sqlSession.close(); } }
From source file:com.quancheng.mybatis.mapper.test.country.TestInsert.java
License:Open Source License
/** * ??/*from w ww . j ava 2 s . co m*/ */ @Test public void testDynamicInsert() { SqlSession sqlSession = MybatisHelper.getSqlSession(); try { CountryMapper mapper = sqlSession.getMapper(CountryMapper.class); Country country = new Country(); country.setId(10086); country.setCountrycode("CN"); country.setCountryname("?"); Assert.assertEquals(1, mapper.insert(country)); //CN2 country = new Country(); country.setCountrycode("CN"); List<Country> list = mapper.select(country); Assert.assertEquals(2, list.size()); //??,?? Assert.assertEquals(1, mapper.deleteByPrimaryKey(10086)); } finally { sqlSession.close(); } }
From source file:com.quancheng.mybatis.mapper.test.country.TestInsert.java
License:Open Source License
/** * ?codenull?,?HH/*from w w w .jav a2 s. c o m*/ */ @Test public void testDynamicInsertNull() { SqlSession sqlSession = MybatisHelper.getSqlSession(); try { CountryMapper mapper = sqlSession.getMapper(CountryMapper.class); Country country = new Country(); country.setId(10086); country.setCountryname("?"); Assert.assertEquals(1, mapper.insert(country)); //CN2 country = new Country(); country.setId(10086); List<Country> list = mapper.select(country); Assert.assertEquals(1, list.size()); Assert.assertNull(list.get(0).getCountrycode()); //??,?? Assert.assertEquals(1, mapper.deleteByPrimaryKey(10086)); } finally { sqlSession.close(); } }
From source file:com.quancheng.mybatis.mapper.test.country.TestInsertSelective.java
License:Open Source License
/** * ??,id?null,/*from w ww .j av a 2s . c o m*/ */ @Test(expected = PersistenceException.class) public void testDynamicInsertAll() { SqlSession sqlSession = MybatisHelper.getSqlSession(); try { CountryMapper mapper = sqlSession.getMapper(CountryMapper.class); mapper.insertSelective(new Country()); } finally { sqlSession.close(); } }