标签:
@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);
}
标签:
原文地址:http://www.cnblogs.com/do-better/p/5421463.html