1. 程式人生 > >java中使用mybatis呼叫儲存過程,拿到返回值(單引數返回值)

java中使用mybatis呼叫儲存過程,拿到返回值(單引數返回值)

service業務層呼叫dao層

注意:返回值直接從物件裡獲取 不需要拿物件接收再獲取

dao.uspGetUser(userPO);//物件封裝了儲存過程的入參和出參
count = userPO.getCount();    //count 是儲存過程的返回值

dao層介面

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

mapper配置檔案

<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>