本文整理匯總了Java中tk.mybatis.mapper.mapper.UserInfoMapMapper類的典型用法代碼示例。如果您正苦於以下問題:Java UserInfoMapMapper類的具體用法?Java UserInfoMapMapper怎麽用?Java UserInfoMapMapper使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
UserInfoMapMapper類屬於tk.mybatis.mapper.mapper包,在下文中一共展示了UserInfoMapMapper類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testInsert
import tk.mybatis.mapper.mapper.UserInfoMapMapper; //導入依賴的package包/類
/**
* 新增
*/
// @Test
public void testInsert() {
SqlSession sqlSession = MybatisHelper.getSqlSession();
try {
UserInfoMapMapper mapper = sqlSession.getMapper(UserInfoMapMapper.class);
UserInfoMap userInfoMap = new UserInfoMap();
userInfoMap.setUserName("abel533");
userInfoMap.setPassword("123456");
userInfoMap.setUserType("2");
Assert.assertEquals(1, mapper.insert(userInfoMap));
Assert.assertNotNull(userInfoMap.getId());
Assert.assertEquals(6, (int)userInfoMap.getId());
Assert.assertEquals(1,mapper.deleteByPrimaryKey(userInfoMap));
} finally {
sqlSession.close();
}
}
示例2: testDelete
import tk.mybatis.mapper.mapper.UserInfoMapMapper; //導入依賴的package包/類
/**
* 主要測試刪除
*/
// @Test
public void testDelete() {
SqlSession sqlSession = MybatisHelper.getSqlSession();
try {
UserInfoMapMapper mapper = sqlSession.getMapper(UserInfoMapMapper.class);
//查詢總數
Assert.assertEquals(5, mapper.selectCount(new UserInfoMap()));
//查詢100
UserInfoMap userInfoMap = mapper.selectByPrimaryKey(1);
//根據主鍵刪除
Assert.assertEquals(1, mapper.deleteByPrimaryKey(1));
//查詢總數
Assert.assertEquals(4, mapper.selectCount(new UserInfoMap()));
//插入
Assert.assertEquals(1, mapper.insert(userInfoMap));
} finally {
sqlSession.close();
}
}
示例3: testUpdateByPrimaryKey
import tk.mybatis.mapper.mapper.UserInfoMapMapper; //導入依賴的package包/類
/**
* 根據主鍵全更新
*/
// @Test
public void testUpdateByPrimaryKey() {
SqlSession sqlSession = MybatisHelper.getSqlSession();
try {
UserInfoMapMapper mapper = sqlSession.getMapper(UserInfoMapMapper.class);
UserInfoMap userInfoMap = mapper.selectByPrimaryKey(2);
Assert.assertNotNull(userInfoMap);
userInfoMap.setUserType(null);
userInfoMap.setRealName("liuzh");
//不會更新user_type
Assert.assertEquals(1, mapper.updateByPrimaryKey(userInfoMap));
userInfoMap = mapper.selectByPrimaryKey(userInfoMap);
Assert.assertNull(userInfoMap.getUserType());
Assert.assertEquals("liuzh",userInfoMap.getRealName());
} finally {
sqlSession.close();
}
}
示例4: testUpdateByPrimaryKeySelective
import tk.mybatis.mapper.mapper.UserInfoMapMapper; //導入依賴的package包/類
/**
* 根據主鍵更新非null
*/
// @Test
public void testUpdateByPrimaryKeySelective() {
SqlSession sqlSession = MybatisHelper.getSqlSession();
try {
UserInfoMapMapper mapper = sqlSession.getMapper(UserInfoMapMapper.class);
UserInfoMap userInfoMap = mapper.selectByPrimaryKey(1);
Assert.assertNotNull(userInfoMap);
userInfoMap.setUserType(null);
userInfoMap.setRealName("liuzh");
//不會更新user_type
Assert.assertEquals(1, mapper.updateByPrimaryKeySelective(userInfoMap));
userInfoMap = mapper.selectByPrimaryKey(1);
Assert.assertEquals("1", userInfoMap.getUserType());
Assert.assertEquals("liuzh",userInfoMap.getRealName());
} finally {
sqlSession.close();
}
}
示例5: testSelect
import tk.mybatis.mapper.mapper.UserInfoMapMapper; //導入依賴的package包/類
/**
* 查詢
*/
// @Test
public void testSelect() {
SqlSession sqlSession = MybatisHelper.getSqlSession();
try {
UserInfoMapMapper mapper = sqlSession.getMapper(UserInfoMapMapper.class);
UserInfoMap userInfoMap = new UserInfoMap();
userInfoMap.setUserType("1");
List<UserInfoMap> UserInfoMaps = mapper.select(userInfoMap);
Assert.assertEquals(3, UserInfoMaps.size());
} finally {
sqlSession.close();
}
}