使用Structs和Arrays处理对象列表时出错。
java.lang.ClassCastException: oracle.sql.StructDescriptor cannot be cast to oracle.sql.ArrayDescriptor
以下是代码:
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);
编辑,添加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
/