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

    package org.dao;
    
    import java.util.List;
    
    import org.apache.ibatis.annotations.Delete;
    import org.apache.ibatis.annotations.Insert;
    import org.apache.ibatis.annotations.One;
    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.Emp;
    
    public interface IEmpMapper {
        /**
         * 
        * @Description: 该方法的主要作用:根据编号删除.
        * @Title: deleteByPrimaryKey
        * @param  @param eid
        * @param  @return 设定文件  
        * @return  返回类型:int   
        * @throws
         */
        @Delete("delete from emp where eid = #{eid} ")
        int deleteByPrimaryKey(Integer eid);
    
        /**
         * 
        * @Description: 该方法的主要作用:添加
        * @Title: insert
        * @param  @param record
        * @param  @return 设定文件  
        * @return  返回类型:int   
        * @throws
         */
        @Insert("insert into emp (eid, ename, eage,  edate, did) " +
                "values (#{eid,jdbcType=INTEGER}," +
                " #{ename,jdbcType=VARCHAR}, " +
                "#{eage,jdbcType=INTEGER},  " +
                "#{edate,jdbcType=TIMESTAMP}," +
                " #{did,jdbcType=INTEGER})")
        int insert(Emp record);
        /**
         * 
        * @Description: 该方法的主要作用:根据编号查询
        * @Title: selectByPrimaryKey
        * @param  @param eid
        * @param  @return 设定文件  
        * @return  返回类型:Emp   
        * @throws
         */
        @Select("select * from emp where eid = #{eid}")
        @Results({
            @Result(id=true,property="eid",column="eid"),
            @Result(property="ename",column="ename"),
            @Result(property="eage",column="eage"),
            @Result(property="dept",column="did",javaType=org.entity.Dept.class,
            one=@One(select="org.dao.IDeptMapper.selectByPrimaryKey"))
        })
        Emp selectByPrimaryKey(Integer eid);
        /**
         * 
        * @Description: 该方法的主要作用:修改信息
        * @Title: updateByPrimaryKey
        * @param  @param record
        * @param  @return 设定文件  
        * @return  返回类型:int   
        * @throws
         */
        @Update("pdate emp " +
                " set ename = #{ename,jdbcType=VARCHAR}, " +
                " eage = #{eage,jdbcType=INTEGER}, " +
                " edate = #{edate,jdbcType=TIMESTAMP}, " +
                "  did = #{did,jdbcType=INTEGER} " +
                "where eid = #{eid,jdbcType=INTEGER}")
        int updateByPrimaryKey(Emp record);
        /**
         * 
        * @Description: 该方法的主要作用:查询全部
        * @Title: findEmpAll
        * @param  @return 设定文件  
        * @return  返回类型:List<Emp>   
        * @throws
         */
        @Select("select * from emp")
        @Results({
            @Result(id=true,property="eid",column="eid"),
            @Result(property="ename",column="ename"),
            @Result(property="eage",column="eage"),
            @Result(property="dept",column="did",javaType=org.entity.Dept.class,
            one=@One(select="org.dao.IDeptMapper.selectByPrimaryKey"))
        })
        List<Emp> findEmpAll();
    
        /**
         * 
        * @Description: 该方法的主要作用:根据部门编号查询员工信息
        * @Title: findEmpByDept
        * @param  @param did
        * @param  @return 设定文件  
        * @return  返回类型:List<Emp>   
        * @throws
         */
        @Select("select * from emp where did = #{dids}")
        @Results({
            @Result(id=true,property="eid",column="eid"),
            @Result(property="ename",column="ename"),
            @Result(property="eage",column="eage"),
            @Result(property="dept",column="did",javaType=org.entity.Dept.class,
            one=@One(select="org.dao.IDeptMapper.selectByPrimaryKey"))
        })
        List<Emp> findEmpByDept(int did);
    
    }
  • 相关阅读:
    撩课-Web大前端每天5道面试题-Day6
    撩课-Python-每天5道面试题-第7天
    撩课-Java每天5道面试题第17天
    撩课-Web架构师养成系列(第二篇)-async
    撩课-Web大前端每天5道面试题-Day5
    撩课-Python-每天5道面试题-第6天
    撩课-Java每天5道面试题第16天
    撩课-Web大前端每天5道面试题-Day4
    撩课-Python-每天5道面试题-第5天
    Three.JS鼠标移动元素(转)
  • 原文地址:https://www.cnblogs.com/a1111/p/12816062.html
Copyright © 2011-2022 走看看