当前位置: 首页>>代码示例>>Java>>正文


Java Country类代码示例

本文整理汇总了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();
    }
}
 
开发者ID:godlike110,项目名称:tk-mybatis,代码行数:18,代码来源:TestDeleteByExample.java

示例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();
    }
}
 
开发者ID:godlike110,项目名称:tk-mybatis,代码行数:18,代码来源:TestSelectByExample.java

示例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();
    }
}
 
开发者ID:Yanweichen,项目名称:MybatisGeneatorUtil,代码行数:17,代码来源:TestSelectCountByExample.java

示例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();
    }
}
 
开发者ID:Yanweichen,项目名称:MybatisGeneatorUtil,代码行数:17,代码来源:TestSelectByExample.java

示例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();
    }
}
 
开发者ID:Yanweichen,项目名称:MybatisGeneatorUtil,代码行数:17,代码来源:TestSelectByExample.java

示例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();
    }
}
 
开发者ID:Yanweichen,项目名称:MybatisGeneatorUtil,代码行数:19,代码来源:TestSelectByExample.java

示例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();
    }
}
 
开发者ID:Yanweichen,项目名称:MybatisGeneatorUtil,代码行数:17,代码来源:TestSelectByExample.java

示例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();
    }
}
 
开发者ID:Yanweichen,项目名称:MybatisGeneatorUtil,代码行数:21,代码来源:TestMysql.java

示例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();
    }
}
 
开发者ID:Yanweichen,项目名称:MybatisGeneatorUtil,代码行数:19,代码来源:TestSelectAll.java

示例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();
    }
}
 
开发者ID:Yanweichen,项目名称:MybatisGeneatorUtil,代码行数:23,代码来源:TestDeleteByPrimaryKey.java

示例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();
    }
}
 
开发者ID:Yanweichen,项目名称:MybatisGeneatorUtil,代码行数:19,代码来源:TestSelectByPrimaryKey.java

示例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();
    }
}
 
开发者ID:Yanweichen,项目名称:MybatisGeneatorUtil,代码行数:20,代码来源:TestSelectByPrimaryKey.java

示例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();
    }
}
 
开发者ID:Yanweichen,项目名称:MybatisGeneatorUtil,代码行数:19,代码来源:TestSelectByPrimaryKey.java

示例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();
    }
}
 
开发者ID:Yanweichen,项目名称:MybatisGeneatorUtil,代码行数:24,代码来源:TestUpdateByPrimaryKeySelective.java

示例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();
    }
}
 
开发者ID:Yanweichen,项目名称:MybatisGeneatorUtil,代码行数:24,代码来源:TestUpdateByPrimaryKey.java


注:本文中的tk.mybatis.mapper.model.Country类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。