本文整理匯總了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();
}
}