2

Oracle SQL:

create or replace TYPE some_array AS TABLE OF NUMBER;

create or replace procedure custom_procedure(array_param IN some_array) (...)

I'm using org.eclipse.persistence 2.x as an implementation of JPA so theoretically it should support such an operation.

Code:

//(... retrieve EntityManager instance => em ...)
StoredProcedureQuery storedProcedure = entityManager.createStoredProcedureQuery("custom_procedure");
storedProcedure.registerStoredProcedureParameter("array_param", Long[].class, ParameterMode.IN);
storedProcedure.setParameter("array_param", new Long[] { 2L });
storedProcedure.executeUpdate();

For above I get:

Internal Exception: java.sql.SQLException: Invalid column type
Error Code: 17004
Chris Jaga
  • 389
  • 4
  • 17
  • Long[] is the java class that you are passing in - it already knows that information from the object itself. What it needs is some way to know that your Long[] should be converted to a "some_array" instance and what that "some_array" type is. You have to define it, and PL/SQL table type isn't supported by JDBC let alone JPA, so you'll have to resort to native annotations and some work described here https://www.eclipse.org/eclipselink/documentation/2.5/solutions/oracledb002.htm – Chris Aug 21 '17 at 14:51

0 Answers0