逆向工程 生成mapper 接口的 重要方法

@Test

public void testSelectByExample() {

ItemsExample itemsExample = new ItemsExample();

ItemsExample.Criteria criteria = itemsExample.createCriteria();

//模糊查询

criteria.andNameLike("%笔%");

//criteria.andNameEqualTo("台式机");

List<Items> list = itemsMapper.selectByExample(itemsExample);

System.out.println(list);

}

 

//按 主键, 更新所有属性

@Test

public void testUpdateByPrimaryKey() {

Items items = itemsMapper.selectByPrimaryKey(1);

itemsMapper.updateByPrimaryKey(items);

}        

 

//按 主键, 更新 不为空 属性

@Test

public void testUpdateByPrimaryKeySelective() {

Items items = new Items();

itemsMapper.updateByPrimaryKeySelective(items);

}

 

//按 条件, 更新所有属性;example:条件;recored:更新对象

@Test

public void testUpdateByPrimaryKeya() {

Items record = null;

ItemsExample example = null;

itemsMapper.updateByExampleSelective(record, example);

}

 

//Order by

@Test

public void testFindAll() {

ItemsExample example = new ItemsExample();

example.setOrderByClause("createtime desc");

itemsMapper.selectByExample(example);                

}

posted @ 2016-04-22 15:29  初冬莽莽  阅读(692)  评论(0编辑  收藏  举报