myBatis中传参类型

2024-11-02 06:15:35

1、员工实体类,省略set,get方法private Integer empno;private String ename;private String job;private Integer mgr;private Date hiredate;private Double sal ;private Double comm;private Integer deptno;部门实体类private Dept dept;

myBatis中传参类型

3、根据姓名查找,传入String类型参数<select id="findByName" parameterType="string" resultType="Emp">select * from t_emp where ename=#{ename}</select>

myBatis中传参类型

4、//根据工号查找public Emp findByNo(Integer empno);<select id="findByNo" parameterType="int" resultType="Emp">select * from t_emp where empno=#{empno}</select>

myBatis中传参类型

5、//插入public void insert(Emp emp);<insert id="insert" parameterType="Emp">insert into t_emp(empno,ename,job,hiredate,mgr,sal,comm,deptno) values(emono_id.nextval,#{ename,jdbcType=VARCHAR} ,#{job,jdbcType=VARCHAR},#{hiredate},#{mgr},#{sal},#{comm,jdbcType=DOUBLE},#{deptno})</insert>

myBatis中传参类型

6、<select id="findRows" parameterType="string&鳎溻趄酃quot; resultType="java.lang.Integer">select count(*) from t_emp where 1=1<if test="ename!=null&amp;&amp;ename.trim()!=''">and ename=#{ename}</if><if test="deptno!=null">and deptno=#{deptno}</if></select>

myBatis中传参类型
猜你喜欢