1. 程式人生 > >mybatis sql語句返回值問題

mybatis sql語句返回值問題

1、update
<pre name="code" class="html"><update id="alterPassword">
        update user_login set password=#{2} where username=#{0} and password=#{1}
    </update>

成功返回: update 執行成功的數目

失敗返回:0

2、select

<select id="hasUser" resultType="int">
        select count(1) from user_login where username=#{0}
    </select>
返回: resultType 型別 ,可以是int,long,自定義的物件等,上面返回的是int
<select id="showFancyById" resultType="com.zc.beauty.model.Fancy">
        select id, s_type, s_name, s_desc, s_brand, s_price, s_image, s_from, s_edittime
        from fancy where id=#{0}
    </select>

返回 com.zc.beauty.model.Fancy 物件

3、insert