1 Myeclipse2015下ibator的安装
找到myEclipse的文件例的eclipse文件夹如:D:\Program Files\MyEclipse 6.0\eclipse里面有两个文件加(features 和 plugins)然后把下载的插件放在这两个文件夹里面,然后,重启MyEclipse即可使用
2 mapper层中各个方法的使用。
User user=new User();
user.setName("123");
user.setPassword("123");
RowBounds rowBound =new RowBounds(0,2);
UserExample example=new UserExample();
Criteria criteria=example.createCriteria();
criteria.andIdBetween(6, 9);//包括4和6
//返回:查询个数
System.out.println("userMapper.countByExample(example):"+userMapper.countByExample(example));
//成功返回1 ,失败返回0
System.out.println("userMapper.insert(user)"+userMapper.insert(user));
//成功返回1 ,失败返回0
System.out.println("userMapper.insertSelective(user)"+userMapper.insertSelective(user));
//返回:删除个数
System.out.println("userMapper.deleteByExample(example)"+userMapper.deleteByExample(example));
//返回:删除个数
System.out.println("userMapper.deleteByPrimaryKey(1)"+userMapper.deleteByPrimaryKey(10));
//返回:成功修改个数
System.out.println("userMapper.updateByExample(user, example)"+userMapper.updateByExample(user, example));
//返回:成功修改个数
System.out.println("userMapper.updateByExampleSelective(user, example)"+userMapper.updateByExampleSelective(user, example));
//返回:成功修改个数
System.out.println("userMapper.updateByPrimaryKey(user)"+userMapper.updateByPrimaryKey(user));
//返回:成功修改个数
System.out.println("userMapper.updateByPrimaryKeySelective(user)"+userMapper.updateByPrimaryKeySelective(user));
//返回:对象集合
System.out.println("userMapper.selectByExample(example)"+userMapper.selectByExample(example));
//页条件 new RowBounds(2,3) 从第2条开始显示,显示3条(从0开始编号) 返回:成功修改个数
System.out.println("userMapper.selectByExampleAndPage(example, rowBound)"+userMapper.selectByExampleAndPage(example, rowBound));
//返回:对象
System.out.println("userMapper.selectByPrimaryKey(1)"+userMapper.selectByPrimaryKey(11));
3 不写SQL的实现:
ShopExample example = new ShopExample();
Criteria c1 = example.createCriteria();
Criteria c2 = example.createCriteria();
example.or(c2);
c1.andSidBetween(1, 100);
c1.andSnameLike("my%");
c2.andSidIsNotNull();
example.setOrderByClause("sprice desc"); //sort field
未完待续。。。