本文整理汇总了Java中tk.mybatis.mapper.mapper.CountryIMapper类的典型用法代码示例。如果您正苦于以下问题:Java CountryIMapper类的具体用法?Java CountryIMapper怎么用?Java CountryIMapper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CountryIMapper类属于tk.mybatis.mapper.mapper包,在下文中一共展示了CountryIMapper类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testINDENTITYInsert
import tk.mybatis.mapper.mapper.CountryIMapper; //导入依赖的package包/类
/**
* 插入完整数据
*/
@Test
public void testINDENTITYInsert() {
SqlSession sqlSession = MybatisHelper.getSqlSession();
try {
CountryIMapper mapper = sqlSession.getMapper(CountryIMapper.class);
CountryI country = new CountryI();
country.setCountrycode("CN");
Assert.assertEquals(1, mapper.insert(country));
//ID会回写
Assert.assertNotNull(country.getId());
//删除插入的数据,以免对其他测试产生影响
Assert.assertEquals(1, mapper.deleteByPrimaryKey(country.getId()));
} finally {
sqlSession.close();
}
}
示例2: testINDENTITYInsertSelective
import tk.mybatis.mapper.mapper.CountryIMapper; //导入依赖的package包/类
/**
* 插入完整数据
*/
@Test
public void testINDENTITYInsertSelective() {
SqlSession sqlSession = MybatisHelper.getSqlSession();
try {
CountryIMapper mapper = sqlSession.getMapper(CountryIMapper.class);
CountryI country = new CountryI();
Assert.assertEquals(1, mapper.insertSelective(country));
//ID会回写
Assert.assertNotNull(country.getId());
//带有默认值的其他的属性不会自动回写,需要手动查询
country = mapper.selectByPrimaryKey(country);
//查询后,默认值不为null
Assert.assertNotNull(country.getCountrycode());
Assert.assertEquals("HH", country.getCountrycode());
//删除插入的数据,以免对其他测试产生影响
Assert.assertEquals(1, mapper.deleteByPrimaryKey(country.getId()));
} finally {
sqlSession.close();
}
}