如何将TYPE COLLECTION参数传递给JPA中的存储过程?

时间:2016-03-08 11:35:21

标签: java eclipse jpa plsql persistence

我在DB中定义了下一个Collection Type:

CREATE OR REPLACE TYPE "TORDEN_CAMPO" AS VARRAY (5) OF VARCHAR2 (9)

现在,我需要调用此存储过程,该过程具有两个TORDEN_CAMPO类型的参数:

    PROCEDURE BUSQUEDA(pivTABLA                  IN VARCHAR2,
                   ...(Parameters)
                   pivPERIODO_EVENTO_FINAL   IN NUMBER,
                   pivCUENTA                 IN VARCHAR2,
                   pivENTIDAD                IN VARCHAR2,
                   pivMACRO                  IN VARCHAR2,
                   pivDEPENDENCIA            IN VARCHAR2,
                   pivIdPARTIC               IN VARCHAR2,
                   ...(More parameters...)
                   pivORDEN_CAMPO            IN tORDEN_CAMPO,
                   pivORDEN_TIPO             IN tORDEN_CAMPO,
                   ...(Moooore parameters...)
                   xmlFinal                  OUT XMLTYPE);

好吧,在Java JPA中,我有这个代码来映射过程:

@NamedStoredProcedureQuery(
    name = "BUSQUEDA",
    procedureName = "PKG_CONSULTA_TRAZABILIDAD.BUSQUEDA",
    parameters = {
       ...(Parameters)
        @StoredProcedureParameter(name="pivPERIODO_EVENTO_INICIAL", mode = ParameterMode.IN, type = Integer.class),
        @StoredProcedureParameter(name="pivPERIODO_EVENTO_FINAL", mode = ParameterMode.IN, type = Integer.class),
        @StoredProcedureParameter(name="pivCUENTA", mode = ParameterMode.IN, type = String.class),
        @StoredProcedureParameter(name="pivENTIDAD", mode = ParameterMode.IN, type = String.class),
        @StoredProcedureParameter(name="pivMACRO", mode = ParameterMode.IN, type = String.class),
        @StoredProcedureParameter(name="pivDEPENDENCIA", mode = ParameterMode.IN, type = String.class),
        @StoredProcedureParameter(name="pivIdPARTIC", mode = ParameterMode.IN, type = String.class),
        ...(More parameters...)
        @StoredProcedureParameter(name="pivORDEN_CAMPO", mode = ParameterMode.IN, type = String[].class),
        @StoredProcedureParameter(name="pivORDEN_TIPO", mode = ParameterMode.IN, type = String[].class),
        ...(Moooooooore parameters...)
        @StoredProcedureParameter(name="xmlFinal", mode = ParameterMode.OUT, type = String.class)
    })

当我拨打电话时,我有下一个错误:

Caused by: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DatabaseException
     

内部异常:java.sql.SQLException:列类型无效   错误代码:17004   致电:BEGIN PKG_CONSULTA_TRAZABILIDAD.BUSQUEDA(pivTABLA =>?,pivIFGD => ?, pivPERIODO_INICIAL => ?, pivPERIODO_FINAL => ?, pivPERIODO_EVENTO_INICIAL => ?, pivPERIODO_EVENTO_FINAL => ?, pivCUENTA => ?, pivENTIDAD =>?,pivMACRO =>?,pivDEPENDENCIA =>?,pivIdPARTIC => ?, pivNifCliente => ?, pivNombCliente => ?, pivNifGrupo => ?, pivNombGrupo =>?,pivCODA => ;?,pivDiferida =>?,pivTI => ?, pivFiltroAnulaciON => ?, pivORDEN_CAMPO => ?, pivORDEN_TIPO => ?, pinREG_INICIAL => ?, pinREG_FINAL => ?, xmlFinal =>? );结束;       bind => [24个参数绑定]   查询:ResultSetMappingQuery()       at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:340)       在org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:682)       在org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:558)       在org.eclipse.persistence.internal.sessions.AbstractSession.basicExecuteCall(AbstractSession.java:2002)       在org.eclipse.persistence.sessions.server.ServerSession.executeCall(ServerSession.java:570)       在org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:242)       在org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:228)       在org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.execute(DatasourceCallQueryMechanism.java:220)       at org.eclipse.persistence.queries.ResultSetMappingQuery.executeDatabaseQuery(ResultSetMappingQuery.java:312)       在org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:899)       at org.eclipse.persistence.queries.DatabaseQuery.executeInUnitOfWork(DatabaseQuery.java:798)       at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2896)       在org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1804)       at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1786)       在org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1751)       在org.eclipse.persistence.internal.jpa.QueryImpl.executeReadQuery(QueryImpl.java:258)       ......还有30多个   引起:java.sql.SQLException:列类型无效       at oracle.jdbc.driver.OraclePreparedStatement.setObjectCritical(OraclePreparedStatement.java:10495)       at oracle.jdbc.driver.OraclePreparedStatement.setObjectInternal(OraclePreparedStatement.java:9974)       at oracle.jdbc.driver.OraclePreparedStatement.setObjectInternal(OraclePreparedStatement.java:10799)       at oracle.jdbc.driver.OracleCallableStatement.setObject(OracleCallableStatement.java:6097)       at oracle.jdbc.driver.OraclePreparedStatementWrapper.setObject(OraclePreparedStatementWrapper.java:241)       在org.eclipse.persistence.internal.databaseaccess.DatabasePlatform.setParameterValueInDatabaseCall(DatabasePlatform.java:2441)       在org.eclipse.persistence.platform.database.oracle.Oracle9Platform.setParameterValueInDatabaseCall(Oracle9Platform.java:525)       在org.eclipse.persistence.internal.databaseaccess.DatabaseCall.prepareStatement(DatabaseCall.java:797)       在org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:619)       ... 44更多

我认为这个错误是我希望传递的数组,所有其余的参数都是字符串或数字...所以我怎么能通过JPA传递这个VARRAY?

0 个答案:

没有答案