1

Getting error with Structs and Arrays handdling list of objects.

java.lang.ClassCastException: oracle.sql.StructDescriptor cannot be cast to oracle.sql.ArrayDescriptor

Here is the code:

List<Commission> commissions = (List<Commission>) parameter;

Struct[] structs = new Struct[commissiones.size()];
for (int index = 0; index < comisions.size(); index++) {
    Object[] params = new Object[9];

    Commission commission = commissions.get(index);

    /* Setting parameters */

    Struct struct = ps.getConnection().createStruct("T_COMMISSION", params);
    structs[index] = struct;
}

Array array = ((OracleConnection)ps.getConnection()).createOracleArray("C_COMMISSION", structs);

ps.setArray(i, array);  

Edit, adding T_COMMISSION:

CREATE OR REPLACE TYPE GESFIN.T_COMMISSION AS OBJECT (COM_MZN VARCHAR2(3),
                                                      COM_PVP VARCHAR2(8),
                                                      -- ..More params)
/

CREATE TYPE C_COMMISSION AS TABLE OF T_COMMISSION
/
Rancio
  • 155
  • 1
  • 3
  • 15

2 Answers2

0

Link to post with the same case

Add

Struct[] struct = new Struct[params.size()];

Change

Struct struct = ps.getConnection().createStruct("T_COMMISSION", params);

to

struct[index] = ps.getConnection().createStruct("T_COMMISSION", params);
Denis Rodin
  • 319
  • 1
  • 7
0

try going in a reversed if loop for (int index = commision.size(); index > -1; index--) {

plus you have a typing error, it is commission, not comision... double check your code and getting a plugin/extension/ad-on to check such error.

Best Regards :-)

UnkownReality
  • 130
  • 13