Problem Details
We are working on a Spring Boot application where in we are connecting to Stored Procs (all returning multiple refcursors) using @NamedStoredProcedureQuery for Oracle 11g DB. We are unable to read data from the second cursor at the same time. As soon as we provide the second result class for the 2nd refcursor we are getting an exception titled Invalid Column Name. Reading 1 cursor works fine.
Exception Details
javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException:
Error extracting results from CallableStatement Caused by:
java.sql.SQLException: Invalid column name
Implementation Details
- STORED PROCEDURE QUERY
@NamedStoredProcedureQuery (
name = "getSP1Data",
procedureName = "package_name",
resultClasses = {Cursor1Response.class, Cursor2Response.class},
parameters = {
@StoredProcedureParameter(type = Integer.class, mode = ParameterMode.IN, name = "in_param_1"),
@StoredProcedureParameter(type = void.class, mode = ParameterMode.REF_CURSOR, name = "cursor_1"),
@StoredProcedureParameter(type = void.class, mode = ParameterMode.REF_CURSOR, name = "curosr_2"),
@StoredProcedureParameter(type = String.class, mode = ParameterMode.INOUT, name = "in_out_param_2") }
)
- CURSOR RESPONSE CLASSES
@Entity
public class Cursor1Response {
@Id
@Column(name = "column_name_1")
private Date column1;
@Column(name = "column_name_2")
private Double column2;
}
@Entity
public class Cursor2Response {
@Id
@Column(name = "column_name_1")
private Date column1;
@Column(name = "column_name_2")
private Double column2;
}
- DAO LAYER IMPLEMENTATION (FROM WHERE WE ACTUALLY CALL OUR STORED PROC QUERY)
StoredProcedureQuery query = entityManager.createNamedStoredProcedureQuery("getSP1Data");
// Code for setting all in params
query.getResultList(); // While execution of this line it is
throwing the above mentioned exception
Has anyone worked on such scenario and have any ideas how to fix this exception?