2014-11-05 3 views
1

MyBatis에서 Annotation을 사용하여 Oracle Function을 호출해야합니다.MyBatis (Annotation Based)로 Oracle 함수 호출하기

내 매퍼 :

@Select("{ CALL #{outParam, jdbcType=NUMERIC, mode=OUT} := ORA_FUNC(" 
    + "#{pNum1, jdbcType=NUMERIC, mode=IN}," 
    + "#{pNum2, jdbcType=NUMERIC, mode=IN}," 
    + "#{pNum3, jdbcType=NUMERIC, mode=IN})}") 
@Options(statementType = StatementType.CALLABLE) 
@ResultType(Integer.class) 
public Integer executeFunction(
    @Param("map") Map<String, Object> carteira); 

이 서명에 내 전화 :

Map<String, Object> mapParameters = new HashMap<String, Object>(); 
mapParameters.put("pNum1", carteira.getUnimedCarteira()); 
mapParameters.put("pNum2", carteira.getCodCarteira()); 
mapParameters.put("pNum3", carteira.getDigitoCarteira()); 
mapper.obterRedeBeneficiario(mapParameters); 
return mapParameters.get("outParam").toString(); 

outParam가 null 매퍼의 반환이 너무 null입니다.

아무도 도와 줄 수 있습니까?

+0

http://stackoverflow.com/questions/26739636/mybatis-mapping- 아래로 maaper을 변경할 수 있습니다 for-fetching-of-custom-record-types-in-oracle/26765161 # 26765161 완전한 예제를 추가했습니다 –

+0

Karthik,이 예제는 XML 기반입니다. 주석 기반의 유사한 비트로 작업 해보십시오 – mEstrazulas

+0

Google에 알려주십시오. 너 무슨 변화가 있었 니? –

답변

2

도메인 클래스 SpInOut 클래스

class SpInOut{ 

    private String outParam; 
    private int pNum1; 
    private int pNum2; 
    private int pNum3; 

    //Getters and setters 

} 

을 만들고

@Select("{ #{outParam, jdbcType=NUMERIC, mode=OUT} = CALL ORA_FUNC(" 
    + "#{pNum1, jdbcType=NUMERIC, mode=IN}," 
    + "#{pNum2, jdbcType=NUMERIC, mode=IN}," 
    + "#{pNum3, jdbcType=NUMERIC, mode=IN})}") 
@Options(statementType = StatementType.CALLABLE) 
public void executeFunction(
    SpInOut inOut); 
당신이 참조 할 수
+0

@ karthik-prasad, 그 작업. 나는 HashMap을 사용하려고 노력하고있다 : '@Select ("{CALL # {map.outParam, jdbcType = NUMERIC, mode = OUT} : = ORA_FUNC ("# map.pNum1, jdbcType = "# {map.pNum1, jdbcType = NUMERIC , 모드 = IN} + "# {map.pNum2, jdbcType = NUMERIC, 모드 = IN}" + "# {map.pNum3, jdbcType = NUMERIC, 모드 = IN})") ") @Options (statementType = StatementType.CALLABLE) @ResultType (Integer.class) 공공 정수 executeFunction ( @Param는 ("지도")지도 <문자열, 개체> carteira)' 감사합니다 – mEstrazulas