在Spring JPA中将OracleType变量作为参数传递

时间:2019-02-21 02:41:43

标签: java oracle hibernate plsql spring-data-jpa

如何在java中创建OracleType变量以通过spring JPA传递给oracle SP。这是我在这里使用的代码片段。

Java代码-

StoredProcedureQuery storedProcedureQuery = em.createStoredProcedureQuery(PROCEDURE_E_FP_VAL);
            storedProcedureQuery.registerStoredProcedureParameter(PARAM_IN_PLAN_CD, String.class, ParameterMode.IN);
            storedProcedureQuery.registerStoredProcedureParameter(PARAM_IN_FND_LIST, OracleType.class, ParameterMode.IN);
            storedProcedureQuery.registerStoredProcedureParameter(PARAM_IN_FIRST_REP_CD, String.class, ParameterMode.IN);
            storedProcedureQuery.registerStoredProcedureParameter(PARAM_IN_SECOND_REP_CD, String.class, ParameterMode.IN);

            storedProcedureQuery.registerStoredProcedureParameter(PARAM_OUT_RTN_CD, String.class, ParameterMode.OUT);
            storedProcedureQuery.registerStoredProcedureParameter(PARAM_OUT_ERR_MSG, String.class, ParameterMode.OUT);
            storedProcedureQuery.registerStoredProcedureParameter(PARAM_OUT_REP1_INVALID_FND, String.class, ParameterMode.OUT);
            storedProcedureQuery.registerStoredProcedureParameter(PARAM_OUT_REP2_INVALID_FND, String.class, ParameterMode.OUT);
            storedProcedureQuery.registerStoredProcedureParameter(PARAM_OUT_INVALID_AGT_CD, String.class, ParameterMode.OUT);

            storedProcedureQuery.setParameter(PARAM_IN_PLAN_CD, plan_cd);
            storedProcedureQuery.setParameter(PARAM_IN_FND_LIST, **fundIds**);
            storedProcedureQuery.setParameter(PARAM_IN_FIRST_REP_CD, first_rep_code.toUpperCase());
            storedProcedureQuery.setParameter(PARAM_IN_SECOND_REP_CD, "");

            logger.info("Calling " + SCHEMA_NAME + "." + "E_FP_VAL", this);

            storedProcedureQuery.execute();

Oracle过程输入/输出参数-

create or replace procedure e_fp_val(pi_plan_cd in varchar2
                                    ,pi_fnd_list in tval_fund
                                    ,pi_first_rep_cd in varchar2
                                    ,pi_second_rep_cd in varchar2 default null
                                    ,po_rtn_cd out varchar2
                                    ,po_err_msg out varchar2
                                    ,po_rep1_invalid_fnd out varchar2
                                    ,po_rep2_invalid_fnd out varchar2
                                    ,po_invld_agt_cd out varchar2
                                   ) IS

**Oracle Type -** 

create or replace TYPE TVAL_FUND AS TABLE of TVAL_FUND_REC;


------------------------------------------------------------------------

此FundIds以String []的形式出现。所以我想将其转换为我不清楚的OracleType对象。

请帮我解决这个问题。

0 个答案:

没有答案