Я хочу выполнить хранимую процедуру в БД Oracle.Я прочитал столько учебников, блогов и т. Д., Сколько смог, но все равно не могу это исправить.
Когда я пытаюсь выполнить хранимую процедуру, я получаю сообщение:
Caused by: org.hibernate.exception.GenericJDBCException: Error registering REF_CURSOR parameter [P_RETURN_VALUE]
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:47)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:113)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:99)
at org.hibernate.engine.jdbc.cursor.internal.StandardRefCursorSupport.registerRefCursorParameter(StandardRefCursorSupport.java:72)
at org.hibernate.query.procedure.internal.ProcedureParameterImpl.prepare(ProcedureParameterImpl.java:283)
at org.hibernate.procedure.internal.ProcedureCallImpl$3.accept(ProcedureCallImpl.java:397)
at org.hibernate.procedure.internal.ProcedureCallImpl$3.accept(ProcedureCallImpl.java:390)
at org.hibernate.query.procedure.internal.ProcedureParameterMetadata.visitRegistrations(ProcedureParameterMetadata.java:186)
at org.hibernate.procedure.internal.ProcedureCallImpl.buildOutputs(ProcedureCallImpl.java:389)
at org.hibernate.procedure.internal.ProcedureCallImpl.getOutputs(ProcedureCallImpl.java:352)
at org.hibernate.procedure.internal.ProcedureCallImpl.outputs(ProcedureCallImpl.java:632)
at org.hibernate.procedure.internal.ProcedureCallImpl.execute(ProcedureCallImpl.java:615)
... 88 more
Caused by: java.sql.SQLException: Ungültiger Spaltentyp: 2012
at oracle.jdbc.driver.OracleStatement.getInternalType(OracleStatement.java:3978)
at oracle.jdbc.driver.OracleCallableStatement.registerOutParameterInternal(OracleCallableStatement.java:140)
at oracle.jdbc.driver.OracleCallableStatement.registerOutParameterInternal(OracleCallableStatement.java:2401)
at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallableStatement.java:2307)
at oracle.jdbc.driver.OracleCallableStatementWrapper.registerOutParameter(OracleCallableStatementWrapper.java:1250)
at weblogic.jdbc.wrapper.CallableStatement_oracle_jdbc_driver_OracleCallableStatementWrapper.registerOutParameter(Unknown Source)
at org.hibernate.engine.jdbc.cursor.internal.StandardRefCursorSupport.registerRefCursorParameter(StandardRefCursorSupport.java:69)
... 96 more
Среда:
- WebLogic 12.2.1.3.0
- Java EE 7
- Hibernate 5.4.1
Служба:
protected void openTransaktion(ArasBenutzer arasBenutzer, String procedureName){
try {
StoredProcedureQuery query = entityManager.createNamedStoredProcedureQuery("TransaktionsProcedureCall.openTransaktion");
query.setParameter("P_ABP_KENNUNG", arasBenutzer.getKennung());
query.execute();
Object obj = query.getResultList();
} catch (Exception e) {
throw new ArasException(String.format(propertiesHelper.getMessage("openTransaktion.fehler"), procedureName), e.getMessage(), ExceptionUtils.getStackTrace(e));
}
}
TransaktionProcedureCall:
@SuppressWarnings("serial")
@Entity
@NamedStoredProcedureQueries({
@NamedStoredProcedureQuery(name = "TransaktionsProcedureCall.openTransaktion", procedureName = "PCK_0212.PPC_OPEN_TRANSACTION", resultClasses = Object.class, parameters = {
@StoredProcedureParameter(name="P_RETURN_VALUE, mode=ParameterMode.REF_CURSOR, type=void.class),
@StoredProcedureParameter(name="P_ABP_KENNUNG", mode=ParameterMode.IN, type=String.class)
})
})
public class TransaktionsProcedureCall extends ProcedureCallAbstract {
}
persistence.xml:
<persistence-unit name="arasPersistenceUnit" transaction-type="JTA">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<jta-data-source>ArasDataSource</jta-data-source>
<properties>
<property name="hibernate.transaction.jta.platform" value="org.hibernate.engine.transaction.jta.platform.internal.WeblogicJtaPlatform" />
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle12cDialect" />
</properties>
</persistence-unit>