zoukankan      html  css  js  c++  java
  • ssm使用全注解实现增删改查案例——IDeptMapper

    package org.dao;
    
    import java.util.List;
    
    import org.apache.ibatis.annotations.Delete;
    import org.apache.ibatis.annotations.Insert;
    import org.apache.ibatis.annotations.Many;
    import org.apache.ibatis.annotations.Result;
    import org.apache.ibatis.annotations.Results;
    import org.apache.ibatis.annotations.Select;
    import org.apache.ibatis.annotations.Update;
    import org.entity.Dept;
    
    public interface IDeptMapper {
        /**
         * 
        * @Description: 该方法的主要作用:删除部门信息
        * @Title: deleteByPrimaryKey
        * @param  @param id
        * @param  @return 设定文件  
        * @return  返回类型:int   
        * @throws
         */
        @Delete("delete from dept where id = #{id}")
        int deleteByPrimaryKey(Integer id);
    
        /**
         * 
        * @Description: 该方法的主要作用:添加部门信息
        * @Title: insert
        * @param  @param record
        * @param  @return 设定文件  
        * @return  返回类型:int   
        * @throws
         */
        @Insert("insert into dept (id, name, loc )" +
                " values (#{id,jdbcType=INTEGER}, " +
                "#{name,jdbcType=VARCHAR}, " +
                "#{loc,jdbcType=VARCHAR})")
        int insert(Dept record);
    
        /**
         * 
        * @Description: 该方法的主要作用:根据编号查询信息
        * @Title: selectByPrimaryKey
        * @param  @param id
        * @param  @return 设定文件  
        * @return  返回类型:Dept   
        * @throws
         */
        @Select("select * from dept where id  = #{id}")
        @Results({
            @Result(id=true,property="id",column="id"),
            @Result(property="name",column="name"),
            @Result(property="loc",column="loc"),
            @Result(property="empList",column="id",javaType=List.class,
            many=@Many(select="org.dao.IEmpMapper.findEmpByDept"))
        })
        Dept selectByPrimaryKey(Integer id);
    
        /**
         * 
        * @Description: 该方法的主要作用:修改信息
        * @Title: updateByPrimaryKey
        * @param  @param record
        * @param  @return 设定文件  
        * @return  返回类型:int   
        * @throws
         */
        @Update("update dept " +
                "set name = #{name,jdbcType=VARCHAR}, " +
                " loc = #{loc,jdbcType=VARCHAR} " +
                "where id = #{id,jdbcType=INTEGER}")
        int updateByPrimaryKey(Dept record);
    
        /**
         * 
        * @Description: 该方法的主要作用:查询全部
        * @Title: findDeptAll
        * @param  @return 设定文件  
        * @return  返回类型:List<Dept>   
        * @throws
         */
        @Select("select * from dept")
        List<Dept> findDeptAll();
    }
  • 相关阅读:
    hdu 4614 线段树 二分
    cf 1066d 思维 二分
    lca 最大生成树 逆向思维 2018 徐州赛区网络预赛j
    rmq学习
    hdu 5692 dfs序 线段树
    dfs序介绍
    poj 3321 dfs序 树状数组 前向星
    cf 1060d 思维贪心
    【PAT甲级】1126 Eulerian Path (25分)
    【PAT甲级】1125 Chain the Ropes (25分)
  • 原文地址:https://www.cnblogs.com/a1111/p/12816063.html
Copyright © 2011-2022 走看看