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);
    
    }
  • 相关阅读:
    jquery 获取easyui combobox选中的值
    一个多余逗号引起的麻烦
    Microsoft.Office.Interop.Excel 放到B/S客户端失败问题 检索 COM 类工厂中 CLSID 为 {00024500-0000-0000-C000-000000000046} 的组件失败,原因是出现以下错误: 80070005 拒绝访问。
    自己收藏-javascript用window.open的子窗口关闭自己并且刷新父窗口
    easyUI datagrid 不刷新问题
    水晶报表中公式字段if else 语句无法正常执行的问题
    SQL SERVER 察看数据库连接池情况
    Data Table 转 List<Type>
    .Net 调用SAP RFC
    VS2017 插件介绍
  • 原文地址:https://www.cnblogs.com/a1111/p/12816062.html
Copyright © 2011-2022 走看看