Myeclipse--ibator工具

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  

未完待续。。。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值