zoukankan      html  css  js  c++  java
  • MyBatis逆向工程生成dao层增删改查方法解释使用(转载)

    int countByExample(BUserExample example); //根据条件查询数量
     
        /**
         * 示例
         * public int countByExample() {
         * BUserExample userExample = new BUserExample();
         * BUserExample.Criteria criteria = userExample.createCriteria();
         * criteria.andUsernameEqualTo("fan");
         * int count = userMapper.countByExample(userExample);
         * return count;
         * }
         * 相当于:select count(*) from user where username = 'fan'
         */
     
        int deleteByExample(BUserExample example); //根据条件删除数据(一条或多条)
     
        /**
         * 示例
         * public int deleteByExample() {
         * BUserExample userExample = new BUserExample();
         * BUserExample.Criteria criteria = userExample.createCriteria();
         * criteria.andUsernameEqualTo("fan");
         * int count = userMapper.deleteByExample(userExample);
         * return count;
         * }
         * 相当于:delete from user where username = 'fan'
         */
     
        int deleteByPrimaryKey(Integer id); //根据主键删除数据
     
        int insert(BUser record); //插入数据(插入一条数据)
     
        int insertSelective(BUser record); //插入数据(插入一条数据,只插入不为null的字段,不会影响有默认值的字段)
     
        List<BUser> selectByExample(BUserExample example); //根据条件查询数据
     
        /**
         * 示例:
         * public List<BUser> getList() {
         * BUserExample userExample = new BUserExample();
         * BUserExample.Criteria criteria = userExample.createCriteria();
         * criteria.andUsernameEqualTo("fan");
         * userExample.setOrderByClause("username desc");
         * List<BUser> users = userMapper.selectByExample(userExample);
         * return users;
         * }
         * 相当于:select * from user where username = 'fan' order by username desc
         */
     
        BUser selectByPrimaryKey(Integer id);  //根据主键查询
     
        int updateByExampleSelective(@Param("record") BUser record, @Param("example") BUserExample example); //按条件更新值不为null的字段
     
        /**
         * 示例:
         * public int updateByParam(String username) {
         * BUserExample userExample = new BUserExample();
         * BUserExample.Criteria criteria = userExample.createCriteria();
         * criteria.andUsernameEqualTo(username);
         * BUser user = new BUser();
         * user.setNickname("jdk");
         * int update = userMapper.updateByExampleSelective(user, userExample);
         * return update;
         * }
         * 相当于:update user set nickname = 'jdk' where username = #{username}
         */
     
        int updateByExample(@Param("record") BUser record, @Param("example") BUserExample example); //按条件更新
     
        int updateByPrimaryKeySelective(BUser record); //根据主键与条件更新
        /**
         * 示例:
         * public int updateByIdAndParam(String username) {
         * BUser user = new BUser();
         * user.setId(101);
         * user.setUsername(username);
         * int update = userMapper.updateByPrimaryKeySelective(user);
         * return update;
         * }
         * 相当于:update user set username = #{username} where id = 101
         */
     
        int updateByPrimaryKey(BUser record); //根据主键更新

    原文链接:https://blog.csdn.net/feidao0/article/details/80731824

  • 相关阅读:
    NSNotificationCenter 使用姿势详解
    自动监测内存泄漏
    Xcode 8:在 Active Compilation Conditions 中自定义环境变量
    iOS 10 推送必看(高阶1)
    iOS10 推送必看(基础篇)
    Xcode 8 用处不大的新特性:CLANG_WARN_INFINITE_RECURSION
    手动实现 KVO
    请谨慎使用 @weakify 和 @strongify
    UIImage图片处理,旋转、截取、平铺、缩放等操作
    Xcode代码格式化教程,可自定义样式
  • 原文地址:https://www.cnblogs.com/qfdy123/p/11565207.html
Copyright © 2011-2022 走看看