Mybatis 多个参数传递的问题

1. 如果传递的是对象

<update id="updatePerson" parameterType="person">

        update person set pname=#{pname},address=#{address} where pid=#{pid}

</update>

2. 使用map传参

<select id="getByCondition" parameterType="java.util.Map" resultType="person">

        select *from person where pname=#{name} and address=#{address}

    </select>

3.根据方法中参数列表的索引值

 <select id="getByCondition2"  resultType="person">

        select *from person where pname=#{0} and address=#{1}

    </select>

4.给参数起别名

 List<PersonBean> getByCondition3(@Param("name") String name, @Param("add") String add); 

<select id="getByCondition3"  resultType="person">

        select *from person where pname=#{name} and address=#{add}

    </select>

猜你喜欢

转载自www.cnblogs.com/masterhxh/p/12896189.html
今日推荐