本文整理汇总了Java中tk.mybatis.mapper.mapper.UserInfoAbleMapper类的典型用法代码示例。如果您正苦于以下问题:Java UserInfoAbleMapper类的具体用法?Java UserInfoAbleMapper怎么用?Java UserInfoAbleMapper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UserInfoAbleMapper类属于tk.mybatis.mapper.mapper包,在下文中一共展示了UserInfoAbleMapper类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testInsert
import tk.mybatis.mapper.mapper.UserInfoAbleMapper; //导入依赖的package包/类
/**
* 新增
*/
@Test
public void testInsert() {
SqlSession sqlSession = MybatisHelper.getSqlSession();
try {
UserInfoAbleMapper mapper = sqlSession.getMapper(UserInfoAbleMapper.class);
UserInfoAble userInfo = new UserInfoAble();
userInfo.setUsername("abel533");
userInfo.setPassword("123456");
userInfo.setUsertype("2");
userInfo.setEmail("[email protected]");//insert=false
Assert.assertEquals(1, mapper.insert(userInfo));
Assert.assertNotNull(userInfo.getId());
Assert.assertEquals(6, (int) userInfo.getId());
userInfo = mapper.selectByPrimaryKey(userInfo.getId());
//email没有插入
Assert.assertNull(userInfo.getEmail());
} finally {
sqlSession.rollback();
sqlSession.close();
}
}
示例2: testUpdateByPrimaryKey
import tk.mybatis.mapper.mapper.UserInfoAbleMapper; //导入依赖的package包/类
/**
* 根据主键全更新
*/
@Test
public void testUpdateByPrimaryKey() {
SqlSession sqlSession = MybatisHelper.getSqlSession();
try {
UserInfoAbleMapper mapper = sqlSession.getMapper(UserInfoAbleMapper.class);
UserInfoAble userInfo = mapper.selectByPrimaryKey(2);
Assert.assertNotNull(userInfo);
userInfo.setUsertype(null);
userInfo.setEmail("[email protected]");
userInfo.setAddress("这个地址不会更新进去");//update=false
//不会更新username
Assert.assertEquals(1, mapper.updateByPrimaryKey(userInfo));
userInfo = mapper.selectByPrimaryKey(userInfo);
Assert.assertNull(userInfo.getUsertype());
Assert.assertNotEquals("这个地址不会更新进去", userInfo.getAddress());
Assert.assertEquals("[email protected]", userInfo.getEmail());
} finally {
sqlSession.rollback();
sqlSession.close();
}
}
示例3: testUpdateByPrimaryKeySelective
import tk.mybatis.mapper.mapper.UserInfoAbleMapper; //导入依赖的package包/类
/**
* 根据主键更新非null
*/
@Test
public void testUpdateByPrimaryKeySelective() {
SqlSession sqlSession = MybatisHelper.getSqlSession();
try {
UserInfoAbleMapper mapper = sqlSession.getMapper(UserInfoAbleMapper.class);
UserInfoAble userInfo = mapper.selectByPrimaryKey(1);
Assert.assertNotNull(userInfo);
userInfo.setUsertype(null);
userInfo.setPassword(null);
userInfo.setAddress("这个地址不会更新进去");
//不会更新username
Assert.assertEquals(1, mapper.updateByPrimaryKeySelective(userInfo));
userInfo = mapper.selectByPrimaryKey(1);
Assert.assertEquals("1", userInfo.getUsertype());
Assert.assertEquals("12345678", userInfo.getPassword());
Assert.assertNotEquals("这个地址不会更新进去", userInfo.getAddress());
} finally {
sqlSession.rollback();
sqlSession.close();
}
}