天天看點

mybatis調用存儲過程,擷取傳回值(單參數傳回值)

service業務層調用dao層

注意:傳回值直接從對象裡擷取 不需要拿對象接收再擷取

dao.uspGetUser(userPO);//對象封裝了存儲過程的入參和出參
    count = userPO.getCount();    //count 是存儲過程的傳回值:從對象在擷取傳回值
           

dao層接口

public interface userDao {
        Integer uspGetUser(UserPO userPO);
    }
           

mapper配置檔案:配置中的count對應UserPO中參數字段

<select id="uspGetUser" statementType="CALLABLE" parameterType="com.entity.UserPO" resultType="integer">
        call usp_get_user(
        #{id,mode=IN,jdbcType=VARCHAR},
        #{name,mode=IN,jdbcType=VARCHAR},
        #{count,mode=OUT,jdbcType=VARCHAR});
    </select>
           

參考::https://blog.csdn.net/qq_38187437/article/details/84872758

繼續閱讀