Search in sources :

Example 6 with UserEntity

use of com.mendmix.mybatis.test.entity.UserEntity in project jeesuite-libs by vakinge.

the class BaseMybatisTest method testCountByExample.

@Test
public void testCountByExample() throws InterruptedException {
    UserEntity example = new UserEntity();
    example.setName("嘎子");
    example.setType((short) 1);
    example.setCreatedAt(new Date());
    userMapper.countByExample(example);
}
Also used : UserEntity(com.mendmix.mybatis.test.entity.UserEntity) Date(java.util.Date) Test(org.junit.Test)

Example 7 with UserEntity

use of com.mendmix.mybatis.test.entity.UserEntity in project jeesuite-libs by vakinge.

the class BaseMybatisTest method testUpdateByPrimaryKey.

@Test
public void testUpdateByPrimaryKey() {
    UserEntity entity = userMapper.selectByPrimaryKey(4);
    entity.setName("jim");
    userMapper.updateByPrimaryKey(entity);
    System.out.println("name:" + entity.getName());
}
Also used : UserEntity(com.mendmix.mybatis.test.entity.UserEntity) Test(org.junit.Test)

Example 8 with UserEntity

use of com.mendmix.mybatis.test.entity.UserEntity in project jeesuite-libs by vakinge.

the class BaseMybatisTest method testPage.

@Test
public void testPage() {
    Page<UserEntity> pageInfo;
    UserEntity example = new UserEntity();
    example.setType((short) 1);
    PageParams pageParams = new PageParams(1, 10, new OrderBy("name"));
    pageInfo = PageExecutor.pagination(pageParams, new PageDataLoader<UserEntity>() {

        @Override
        public List<UserEntity> load() {
            return userMapper.selectByExample(example);
        }
    });
    System.out.println(pageInfo);
}
Also used : OrderBy(com.mendmix.common.model.OrderBy) PageParams(com.mendmix.common.model.PageParams) PageDataLoader(com.mendmix.mybatis.plugin.pagination.PageExecutor.PageDataLoader) UserEntity(com.mendmix.mybatis.test.entity.UserEntity) Test(org.junit.Test)

Example 9 with UserEntity

use of com.mendmix.mybatis.test.entity.UserEntity in project jeesuite-libs by vakinge.

the class BaseMybatisTest method testUpdateVersion.

@Test
public void testUpdateVersion() {
    UserEntity entity = userMapper.selectByPrimaryKey(4);
    // userMapper.insert(entity);
    // userMapper.deleteByPrimaryKey(entity.getId());
    entity.setName(RandomStringUtils.random(5, true, false));
    entity.setStatus((short) 1);
    entity.setVersion(4);
    int result = userMapper.updateByPrimaryKeyWithVersion(entity);
    System.out.println(result);
}
Also used : UserEntity(com.mendmix.mybatis.test.entity.UserEntity) Test(org.junit.Test)

Example 10 with UserEntity

use of com.mendmix.mybatis.test.entity.UserEntity in project jeesuite-libs by vakinge.

the class BaseMybatisTest method testUpdateByPrimaryKeySelective.

@Test
public void testUpdateByPrimaryKeySelective() {
    UserEntity entity = userMapper.selectByPrimaryKey(4);
    entity.setName("jim2");
    userMapper.updateByPrimaryKeySelective(entity);
    System.out.println("name:" + entity.getName());
}
Also used : UserEntity(com.mendmix.mybatis.test.entity.UserEntity) Test(org.junit.Test)

Aggregations

UserEntity (com.mendmix.mybatis.test.entity.UserEntity)10 Test (org.junit.Test)9 Date (java.util.Date)2 OrderBy (com.mendmix.common.model.OrderBy)1 PageParams (com.mendmix.common.model.PageParams)1 PageDataLoader (com.mendmix.mybatis.plugin.pagination.PageExecutor.PageDataLoader)1 HashMap (java.util.HashMap)1