本文整理汇总了Java中tk.mybatis.mapper.model.Country类的典型用法代码示例。如果您正苦于以下问题:Java Country类的具体用法?Java Country怎么用?Java Country使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Country类属于tk.mybatis.mapper.model包,在下文中一共展示了Country类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDeleteByExample2
import tk.mybatis.mapper.model.Country; //导入依赖的package包/类
@Test
public void testDeleteByExample2() {
SqlSession sqlSession = MybatisHelper.getSqlSession();
try {
CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
Example example = new Example(Country.class);
example.createCriteria().andLike("countryname", "A%");
example.or().andGreaterThan("id", 100);
example.setDistinct(true);
int count = mapper.deleteByExample(example);
//查询总数
Assert.assertEquals(true, count > 83);
} finally {
sqlSession.rollback();
sqlSession.close();
}
}
示例2: testAndExample
import tk.mybatis.mapper.model.Country; //导入依赖的package包/类
@Test
public void testAndExample() {
SqlSession sqlSession = MybatisHelper.getSqlSession();
try {
CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
Example example = new Example(Country.class);
example.createCriteria()
.andCondition("countryname like 'C%' and id < 100")
.andCondition("length(countryname) = ", 5)
.andCondition("countrycode =", "CN", StringTypeHandler.class);
List<Country> countries = mapper.selectByExample(example);
//查询总数
Assert.assertEquals(1, countries.size());
} finally {
sqlSession.close();
}
}
示例3: testSelectCountByExample2
import tk.mybatis.mapper.model.Country; //导入依赖的package包/类
@Test
public void testSelectCountByExample2() {
SqlSession sqlSession = MybatisHelper.getSqlSession();
try {
CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
Example example = new Example(Country.class);
example.createCriteria().andLike("countryname", "A%");
example.or().andGreaterThan("id", 100);
example.setDistinct(true);
int count = mapper.selectCountByExample(example);
//查询总数
Assert.assertEquals(true, count > 83);
} finally {
sqlSession.close();
}
}
示例4: testSelectByExample2
import tk.mybatis.mapper.model.Country; //导入依赖的package包/类
@Test
public void testSelectByExample2() {
SqlSession sqlSession = MybatisHelper.getSqlSession();
try {
CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
Example example = new Example(Country.class);
example.createCriteria().andLike("countryname", "A%");
example.or().andGreaterThan("id", 100);
example. setDistinct(true);
List<Country> countries = mapper.selectByExample(example);
//查询总数
Assert.assertEquals(true, countries.size() > 83);
} finally {
sqlSession.close();
}
}
示例5: testSelectByExample3
import tk.mybatis.mapper.model.Country; //导入依赖的package包/类
@Test
public void testSelectByExample3() {
SqlSession sqlSession = MybatisHelper.getSqlSession();
try {
CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
CountryExample example = new CountryExample();
example.createCriteria().andCountrynameLike("A%");
example.or().andIdGreaterThan(100);
example.setDistinct(true);
List<Country> countries = mapper.selectByExample(example);
//查询总数
Assert.assertEquals(true, countries.size() > 83);
} finally {
sqlSession.close();
}
}
示例6: testSelectByExample4
import tk.mybatis.mapper.model.Country; //导入依赖的package包/类
@Test
public void testSelectByExample4() {
SqlSession sqlSession = MybatisHelper.getSqlSession();
try {
Country ct = new Country();
ct.setCountryname("China");
CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
Example example = new Example(Country.class);
example.createCriteria().andGreaterThan("id", 20).andEqualTo(ct);
List<Country> countries = mapper.selectByExample(example);
//查询总数
System.out.println(countries.get(0).toString());
Assert.assertEquals(1, countries.size());
} finally {
sqlSession.close();
}
}
示例7: testSelectColumnsByExample
import tk.mybatis.mapper.model.Country; //导入依赖的package包/类
@Test
public void testSelectColumnsByExample() {
SqlSession sqlSession = MybatisHelper.getSqlSession();
try {
CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
Example example = new Example(Country.class);
example.createCriteria().andGreaterThan("id", 100).andLessThan("id", 151);
example.or().andLessThan("id", 41);
example.selectProperties("id", "countryname", "hehe");
List<Country> countries = mapper.selectByExample(example);
//查询总数
Assert.assertEquals(90, countries.size());
} finally {
sqlSession.close();
}
}
示例8: testInsert
import tk.mybatis.mapper.model.Country; //导入依赖的package包/类
/**
* 插入完整数据
*/
//该方法测试需要mysql或者h2数据库,所以这里注释掉
//@Test
public void testInsert() {
SqlSession sqlSession = MybatisHelper.getSqlSession();
try {
CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
Country country = new Country();
country.setCountrycode("CN");
country.setCountryname("天朝");
int count = mapper.insertUseGeneratedKeys(country);
Assert.assertEquals(1, count);
Assert.assertNotNull(country.getId());
} finally {
sqlSession.rollback();
sqlSession.close();
}
}
示例9: testDynamicSelectPage2
import tk.mybatis.mapper.model.Country; //导入依赖的package包/类
/**
* 查询全部
*/
@Test
public void testDynamicSelectPage2() {
SqlSession sqlSession = MybatisHelper.getSqlSession();
try {
CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
List<Country> countryList = mapper.selectAll();
//查询总数
Assert.assertEquals(183, countryList.size());
//selectAll有排序
Assert.assertEquals(183, (int) countryList.get(0).getId());
} finally {
sqlSession.close();
}
}
示例10: testDynamicDelete
import tk.mybatis.mapper.model.Country; //导入依赖的package包/类
/**
* 主要测试删除
*/
@Test
public void testDynamicDelete() {
SqlSession sqlSession = MybatisHelper.getSqlSession();
try {
CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
//查询总数
Assert.assertEquals(183, mapper.selectCount(new Country()));
//查询100
Country country = mapper.selectByPrimaryKey(100);
//根据主键删除
Assert.assertEquals(1, mapper.deleteByPrimaryKey(100));
//查询总数
Assert.assertEquals(182, mapper.selectCount(new Country()));
//插入
Assert.assertEquals(1, mapper.insert(country));
} finally {
sqlSession.close();
}
}
示例11: testDynamicSelectByPrimaryKey2
import tk.mybatis.mapper.model.Country; //导入依赖的package包/类
/**
* 根据PK进行查询
*/
@Test
public void testDynamicSelectByPrimaryKey2() {
SqlSession sqlSession = MybatisHelper.getSqlSession();
try {
CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
Country country = mapper.selectByPrimaryKey(35);
Assert.assertNotNull(country);
Assert.assertEquals(true, country.getId() == 35);
Assert.assertEquals("China", country.getCountryname());
Assert.assertEquals("CN", country.getCountrycode());
} finally {
sqlSession.close();
}
}
示例12: testDynamicSelectByPrimaryKey
import tk.mybatis.mapper.model.Country; //导入依赖的package包/类
/**
* 包含主键的对象做参数就行
*/
@Test
public void testDynamicSelectByPrimaryKey() {
SqlSession sqlSession = MybatisHelper.getSqlSession();
try {
CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
Country country = new Country();
country.setId(35);
country = mapper.selectByPrimaryKey(country);
Assert.assertNotNull(country);
Assert.assertEquals(true, country.getId() == 35);
Assert.assertEquals("China", country.getCountryname());
Assert.assertEquals("CN", country.getCountrycode());
} finally {
sqlSession.close();
}
}
示例13: testDynamicSelectByPrimaryKeyZero
import tk.mybatis.mapper.model.Country; //导入依赖的package包/类
/**
* 查询不存在的结果
*/
@Test
public void testDynamicSelectByPrimaryKeyZero() {
SqlSession sqlSession = MybatisHelper.getSqlSession();
try {
CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
Assert.assertNull(mapper.selectByPrimaryKey(new Country()));
Assert.assertNull(mapper.selectByPrimaryKey(new HashMap<String,Object>()));
Assert.assertNull(mapper.selectByPrimaryKey(-10));
Assert.assertNull(mapper.selectByPrimaryKey(0));
Assert.assertNull(mapper.selectByPrimaryKey(1000));
Assert.assertNull(mapper.selectByPrimaryKey(null));
} finally {
sqlSession.close();
}
}
示例14: testDynamicUpdateByPrimaryKeySelective
import tk.mybatis.mapper.model.Country; //导入依赖的package包/类
/**
* 根据查询条件进行查询
*/
@Test
public void testDynamicUpdateByPrimaryKeySelective() {
SqlSession sqlSession = MybatisHelper.getSqlSession();
try {
CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
Country country = new Country();
country.setId(173);
country.setCountryname("英国");
Assert.assertEquals(1, mapper.updateByPrimaryKeySelective(country));
country = mapper.selectByPrimaryKey(173);
Assert.assertNotNull(country);
Assert.assertEquals(173, (int) country.getId());
Assert.assertEquals("英国", country.getCountryname());
Assert.assertNotNull(country.getCountrycode());
Assert.assertEquals("GB", country.getCountrycode());
} finally {
sqlSession.close();
}
}
示例15: testDynamicUpdateByPrimaryKey
import tk.mybatis.mapper.model.Country; //导入依赖的package包/类
/**
* 根据查询条件进行查询
*/
@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();
}
}