2014-04-12 8 views
0

Oracle 저장 프로 시저를 호출하고 Oracle 저장 프로 시저에서 출력 매개 변수를 가져 오는 데 문제가 있습니다. 가 여기에 내가 여러 옵션을 시도했다 그것은 오류를Mybatis Oracle 저장 프로 시저

DEBUG 2014-04-12 09:51:56,948 org.apache.ibatis.logging.commons.JakartaCommonsLoggingImpl: ==> Preparing: { CALL sp_check_user(?, ?, ?) } 
DEBUG 2014-04-12 09:51:57,103 org.apache.ibatis.logging.commons.JakartaCommonsLoggingImpl: ==> Parameters: abc(String), abc1(String) 

Could not complete request 
    java.lang.NullPointerException 
     at com.appuser.dao.AppUserDaoImpl.getUserType(AppUserDaoImpl.java:33) 

을 저장 프로 시저를 실행하지만주고있다

CREATE OR REPLACE PROCEDURE HR.sp_check_user (userId VARCHAR,userPwd VARCHAR, userType OUT VARCHAR) 
AS 
BEGIN 
    BEGIN 

    select user_type into userType from appuser where USER_ID = userId and USER_PWD = userPwd ; 
    EXCEPTION 
    WHEN NO_DATA_FOUND THEN 
     userType := 'Invalid';  
    END ; 
END ; 
/

프로 시저 코드를 저장한다 AppUserMapper.java

다음
public interface AppUserMapper { 
    @Select(value= "{ CALL sp_check_user( #{userId, mode=IN, jdbcType=VARCHAR }, #{userPwd, mode=IN, jdbcType=VARCHAR}, #{userType, jdbcType=VARCHAR, mode=OUT})}") 
    @Options(statementType = StatementType.CALLABLE) 
    Object getUserType(String userId,String UserPwd); 
} 

Dao call 
    Map<String, Object> retrurnStatus = (Map<String, Object>) appUserMapper.getUserType(userId,UserPwd); 

을 내 매퍼 하지만, 내가 취할 수있는 샘플을 찾지 못했습니다.

나는 다중 입력 및 출력 매개 변수가있는 mybatis에 오라클 저장 procs를 사용하려고 했으므로 이에 대한 적절한 도움을 전달할 것입니다.

누군가 다중 입력 출력 매개 변수에 대해 mybatis를 사용하여 Oracle 저장 프로 시저를 호출하는 간단한 예제를 제공 할 수 있습니까?

답변

0

제프 버틀러는 mybatis-user group 말한다 :

저장 프로 시저 매개 변수의 경우, MyBatis로 입력하고 parameterType의 속성 출력 매개 변수를 모두 매핑합니다.

당신은지도, POJO 또는 userId, userPwduserType을 가진 세 개의 주석 변수를 전달 시도 할 수 있습니다. SP가 호출 된 후 MyBatis는 OUT 매개 변수를 userType으로 설정합니다.

나는 지금 시도 할 수 없다. 나는 나중에 대답을 편집하려고 노력할 것이다. 하지만 이것들을 시도 할 수 있습니까?

1) 다음과 같이 함수를 정의하고 SP를 호출 한 후 userType이 업데이트되었는지 확인하십시오.

void getUserType(Param("userId") String userId, Param("userPwd") String userPwd, Param("userType") String userType); 

또는

2

) 3 키 - 값 쌍, 즉, ("userId를", 1234), ("userPwd", 666), ("유저 유형, 널 (null)) 튜플을 추가,지도를 작성합니다. 당신이 SP를 호출 한 후에는 유저 유형 값을 받고 시도 할 수 있습니다.

void getUserType(Map<String, Object> myMap); 

또는

3

) 3 개 변수 (userId를, userPwd, 유저 유형), 게터, 세터와 클래스를 작성합니다. 설정 ID와 userPwd을 값을 호출하고 SP를 호출하면 userObj.getUserType().

void getUserType(UserClass userObj); 
+0

또한, 중복 질문이/여기에 대답 : http://stackoverflow.com/questions/7817185/cannot-receive-out-parameter-from-oracle-procedure-executed-by-mybatis?rq = 1 – yalpertem