java - ClassCastException when reading OUT parameters from EclipseLink PLSQLStoredProcedureCall -


i need call oracle stored procedure using eclipselink (2.3.1.v20111018-r10243). procedure have in , out parameters, , need read out parameter.

i found this example , code pretty copy of example, instead of receiving list api, throwing exception because value integer of value "1", , can't figure out why.

the procedure being called properly, in parameter ok, code fails read response "should" list according example.

import java.util.arraylist; import java.util.list;  import javax.ejb.stateless; import javax.persistence.entitymanager; import javax.persistence.persistencecontext;  import org.eclipse.persistence.jpa.jpaentitymanager; import org.eclipse.persistence.platform.database.jdbc.jdbctypes; import org.eclipse.persistence.platform.database.oracle.plsql.oracleplsqltypes; import org.eclipse.persistence.platform.database.oracle.plsql.plsqlstoredprocedurecall; import org.eclipse.persistence.queries.datamodifyquery; import org.eclipse.persistence.sessions.databaserecord; import org.eclipse.persistence.sessions.session;  public class procedurecall {      @persistencecontext     private entitymanager em;      public string execute(long parameter) throws exception {          plsqlstoredprocedurecall call = new plsqlstoredprocedurecall();          call.setprocedurename("two_arg_in_out");         call.addnamedoutputargument("x", oracleplsqltypes.binaryinteger);         call.addnamedargument("y", jdbctypes.varchar_type, 40);          datamodifyquery query = new datamodifyquery();         query.setcall(call);         query.addargument("y");          list queryargs = new arraylist();         queryargs.add(parameter);          session session = ((jpaentitymanager) em.getdelegate()).getactivesession();         object obj = session.executequery(query, queryargs);          // system prints "return: 1"         system.out.println("return: " + obj);          list results = (list) obj; // here exception happens          databaserecord record = (databaserecord) results.get(0);         string y = (string) record.get("x");          return "done";     }  } 

the system throws following exception:

caused by: java.lang.classcastexception: java.lang.integer cannot cast java.util.list 

this procedure example using:

procedure two_arg_in_out(x out binary_integer, y in varchar) begin  x := 33; end; 

this looks similar example shown here: https://wiki.eclipse.org/eclipselink/examples/jpa/nonjdbcargstostoredprocedures#handling_in_and_out_arguments

the difference using datamodifyquery designed around jdbc's executeupdate execute query, , returns int instead of resultset. want use datareadquery obtain results.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -