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


Java UserInfoMapper类代码示例

本文整理汇总了Java中tk.mybatis.mapper.mapper.UserInfoMapper的典型用法代码示例。如果您正苦于以下问题:Java UserInfoMapper类的具体用法?Java UserInfoMapper怎么用?Java UserInfoMapper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: testDelete

import tk.mybatis.mapper.mapper.UserInfoMapper; //导入依赖的package包/类
/**
 * 主要测试删除
 */
@Test
public void testDelete() {
    SqlSession sqlSession = MybatisHelper.getSqlSession();
    try {
        UserInfoMapper mapper = sqlSession.getMapper(UserInfoMapper.class);
        //查询总数
        Assert.assertEquals(5, mapper.selectCount(new UserInfo()));
        //查询100
        UserInfo userInfo = mapper.selectByPrimaryKey(1);


        //根据主键删除
        Assert.assertEquals(1, mapper.deleteByPrimaryKey(1));


        //查询总数
        Assert.assertEquals(4, mapper.selectCount(new UserInfo()));
        //插入
        Assert.assertEquals(1, mapper.insert(userInfo));
    } finally {
        sqlSession.rollback();
        sqlSession.close();
    }
}
 
开发者ID:Yanweichen,项目名称:MybatisGeneatorUtil,代码行数:28,代码来源:TestBasic.java

示例2: testUpdateByPrimaryKey

import tk.mybatis.mapper.mapper.UserInfoMapper; //导入依赖的package包/类
/**
 * 根据主键全更新
 */
@Test
public void testUpdateByPrimaryKey() {
    SqlSession sqlSession = MybatisHelper.getSqlSession();
    try {
        UserInfoMapper mapper = sqlSession.getMapper(UserInfoMapper.class);
        UserInfo userInfo = mapper.selectByPrimaryKey(2);
        Assert.assertNotNull(userInfo);
        userInfo.setUsertype(null);
        userInfo.setEmail("[email protected]");
        //不会更新username
        Assert.assertEquals(1, mapper.updateByPrimaryKey(userInfo));

        userInfo = mapper.selectByPrimaryKey(userInfo);
        Assert.assertNull(userInfo.getUsertype());
        Assert.assertEquals("[email protected]", userInfo.getEmail());
    } finally {
        sqlSession.rollback();
        sqlSession.close();
    }
}
 
开发者ID:Yanweichen,项目名称:MybatisGeneatorUtil,代码行数:24,代码来源:TestBasic.java

示例3: testUpdateByPrimaryKeySelective

import tk.mybatis.mapper.mapper.UserInfoMapper; //导入依赖的package包/类
/**
 * 根据主键更新非null
 */
@Test
public void testUpdateByPrimaryKeySelective() {
    SqlSession sqlSession = MybatisHelper.getSqlSession();
    try {
        UserInfoMapper mapper = sqlSession.getMapper(UserInfoMapper.class);
        UserInfo userInfo = mapper.selectByPrimaryKey(1);
        Assert.assertNotNull(userInfo);
        userInfo.setUsertype(null);
        userInfo.setEmail("[email protected]");
        //不会更新username
        Assert.assertEquals(1, mapper.updateByPrimaryKeySelective(userInfo));

        userInfo = mapper.selectByPrimaryKey(1);
        Assert.assertEquals("1", userInfo.getUsertype());
        Assert.assertEquals("[email protected]", userInfo.getEmail());
    } finally {
        sqlSession.rollback();
        sqlSession.close();
    }
}
 
开发者ID:Yanweichen,项目名称:MybatisGeneatorUtil,代码行数:24,代码来源:TestBasic.java

示例4: testInsert

import tk.mybatis.mapper.mapper.UserInfoMapper; //导入依赖的package包/类
/**
 * 新增
 */
@Test
public void testInsert() {
    SqlSession sqlSession = MybatisHelper.getSqlSession();
    try {
        UserInfoMapper mapper = sqlSession.getMapper(UserInfoMapper.class);
        UserInfo userInfo = new UserInfo();
        userInfo.setUsername("abel533");
        userInfo.setPassword("123456");
        userInfo.setUsertype("2");
        userInfo.setEmail("[email protected]");
        Collection collection = sqlSession.getConfiguration().getMappedStatements();
        for (Object o : collection) {
            if(o instanceof MappedStatement){
                MappedStatement ms = (MappedStatement) o;
                if (ms.getId().contains("UserInfoMapper.insert")) {
                    System.out.println(ms.getId());
                }
            }
        }

        Assert.assertEquals(1, mapper.insert(userInfo));

        Assert.assertNotNull(userInfo.getId());
        Assert.assertTrue((int) userInfo.getId() >= 6);

        Assert.assertEquals(1,mapper.deleteByPrimaryKey(userInfo));
    } finally {
        sqlSession.rollback();
        sqlSession.close();
    }
}
 
开发者ID:Yanweichen,项目名称:MybatisGeneatorUtil,代码行数:35,代码来源:TestBasic.java

示例5: testSelect

import tk.mybatis.mapper.mapper.UserInfoMapper; //导入依赖的package包/类
/**
 * 查询
 */
@Test
public void testSelect() {
    SqlSession sqlSession = MybatisHelper.getSqlSession();
    try {
        UserInfoMapper mapper = sqlSession.getMapper(UserInfoMapper.class);
        UserInfo userInfo = new UserInfo();
        userInfo.setUsertype("1");
        List<UserInfo> userInfos = mapper.select(userInfo);
        Assert.assertEquals(3, userInfos.size());
    } finally {
        sqlSession.close();
    }
}
 
开发者ID:Yanweichen,项目名称:MybatisGeneatorUtil,代码行数:17,代码来源:TestBasic.java


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