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


Java Country.setId方法代码示例

本文整理汇总了Java中tk.mybatis.mapper.model.Country.setId方法的典型用法代码示例。如果您正苦于以下问题:Java Country.setId方法的具体用法?Java Country.setId怎么用?Java Country.setId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tk.mybatis.mapper.model.Country的用法示例。


在下文中一共展示了Country.setId方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: testAllColumns

import tk.mybatis.mapper.model.Country; //导入方法依赖的package包/类
/**
 * 查询全部
 */
@Test
public void testAllColumns() {
    SqlSession sqlSession = MybatisHelper.getSqlSession();
    try {
        CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
        Country country = new Country();
        //35,'China','CN'
        country.setCountrycode("CN");
        country.setId(35);
        country.setCountryname("China");
        List<Country> countryList = mapper.select(country);
        Assert.assertEquals(1, countryList.size());
    } finally {
        sqlSession.close();
    }
}
 
开发者ID:Yanweichen,项目名称:MybatisGeneatorUtil,代码行数:20,代码来源:TestSelect.java

示例5: testDynamicExistsWithPrimaryKey

import tk.mybatis.mapper.model.Country; //导入方法依赖的package包/类
/**
 * 根据PK进行查询
 */
@Test
public void testDynamicExistsWithPrimaryKey() {
    SqlSession sqlSession = MybatisHelper.getSqlSession();
    try {
        CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
        Country country = new Country();
        country.setId(35);
        Assert.assertEquals(true, mapper.existsWithPrimaryKey(country));

        country.setId(0);
        Assert.assertEquals(false, mapper.existsWithPrimaryKey(country));
    } finally {
        sqlSession.close();
    }
}
 
开发者ID:godlike110,项目名称:tk-mybatis,代码行数:19,代码来源:TestExistsWithPrimaryKey.java

示例6: testDynamicDeleteEntity

import tk.mybatis.mapper.model.Country; //导入方法依赖的package包/类
/**
 * 对象包含主键即可
 */
@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();
    }
}
 
开发者ID:Yanweichen,项目名称:MybatisGeneatorUtil,代码行数:17,代码来源:TestDeleteByPrimaryKey.java


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