當前位置: 首頁>>代碼示例>>Java>>正文


Java UserInfoAbleMapper類代碼示例

本文整理匯總了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();
    }
}
 
開發者ID:Yanweichen,項目名稱:MybatisGeneatorUtil,代碼行數:28,代碼來源:TestBasicAble.java

示例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();
    }
}
 
開發者ID:Yanweichen,項目名稱:MybatisGeneatorUtil,代碼行數:26,代碼來源:TestBasicAble.java

示例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();
    }
}
 
開發者ID:Yanweichen,項目名稱:MybatisGeneatorUtil,代碼行數:26,代碼來源:TestBasicAble.java


注:本文中的tk.mybatis.mapper.mapper.UserInfoAbleMapper類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。