1

I am trying to call a stored procedure which returns a non entity object using JPA. Here is what I do.

StoredProcedureQuery query = entityManager.createStoredProcedureQuery(
            "DepAndTerm", "CalendarsMapping");

query.registerStoredProcedureParameter(0, String.class, ParameterMode.IN);
query.registerStoredProcedureParameter(1, String.class, ParameterMode.IN);
query.registerStoredProcedureParameter(2, String.class, ParameterMode.IN);
query.registerStoredProcedureParameter(3, String.class, ParameterMode.IN);
query.registerStoredProcedureParameter(4, void.class, ParameterMode.REF_CURSOR);

query.setParameter(0, startDate);
query.setParameter(1, endDate);
query.setParameter(2, eventType);
query.setParameter(3, tType);

query.execute();

List<TCalendar> tCalendars = (List<TCalendar>) query.getOutputParameterValue(4);

@SqlResultSetMapping(
  name = "CalendarsMapping",
  classes = {
    @ConstructorResult(
      targetClass = TCalendar.class,
      columns = {
        @ColumnResult(name="BOutDate"),                 
        @ColumnResult(name="CategoryID"),
        @ColumnResult(name="CategoryName")
      }
    )
  }
)

I am getting following exception

java.lang.UnsupportedOperationException: org.hibernate.dialect.Oracle10gDialect does not support resultsets via stored procedures
at org.hibernate.dialect.Dialect.getResultSet(Dialect.java:1645) ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final]
at org.hibernate.engine.jdbc.cursor.internal.StandardRefCursorSupport.getResultSet(StandardRefCursorSupport.java:125) ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final]
at org.hibernate.procedure.internal.ProcedureOutputsImpl$ProcedureCurrentReturnState.buildExtendedReturn(ProcedureOutputsImpl.java:106) ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final]
at org.hibernate.result.internal.OutputsImpl$CurrentReturnState.buildOutput(OutputsImpl.java:209) ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final]
at org.hibernate.result.internal.OutputsImpl$CurrentReturnState.getOutput(OutputsImpl.java:187) ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final]
at org.hibernate.result.internal.OutputsImpl.getCurrent(OutputsImpl.java:108) ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final]
at org.hibernate.jpa.internal.StoredProcedureQueryImpl.execute(StoredProcedureQueryImpl.java:234) ~[hibernate-entitymanager-4.3.11.Final.jar:4.3.11.Final]

I don't know what I doing wrong.

1

1 Answer 1

0

Updating to 12c dialect in Hibernate 5.x solved the problem. I was using hibernate 4.2 and 10g dialect.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.