title: Calling through Spring a procedure with collection of object (oracle ARRAY STRUCT)
body: <p>im trying to execute a procedure which contains between others a parameter which is a collection of object (oracle). I have managed them lot of times without spring, but I'm a bit lost trying to do it with spring, althoug there is some information on the internet, I can't find a full example in order to compare my code. Spring doc has just fragments. Probably my code is wrong but i ignore why, could you help me? I'm running simplier procedures without problems. My DAO looks like this:</p>
  
  <pre><code>//[EDITED]
  private SimpleJdbcCall pActualizaDia;
  
  ....
  
  @Autowired
  public void setDataSource(DataSource dataSource) {
    pActualizaDia = new SimpleJdbcCall(dataSource).withCatalogName("PTR_GRUPOS_TRABAJO").withProcedureName("UPDATE_DIA");
    pActualizaDia.getJdbcTemplate().setNativeJdbcExtractor(new OracleJdbc4NativeJdbcExtractor());
  }
  ...
  
   public Calendario updateSingle(final Calendario calendario) {
  
      SqlTypeValue cambiosEmpresa = new AbstractSqlTypeValue() {
  
      protected Object createTypeValue(Connection conn, int sqlType, String typeName) throws SQLException {
  
      ArrayDescriptor arrayDescriptor = new ArrayDescriptor("TTPTR_CAMBIO_EMPRESA", conn);
  
      Object[] collection = new Object[calendario.getCambiosEmpresa().size()];
      int i = 0;
      for (CeAnoEmp ce : calendario.getCambiosEmpresa()) {
          collection[i++] = new STRUCT(new StructDescriptor("TPTR_CAMBIO_EMPRESA", conn), conn, new Object[] {
              ce.getSQLParam1(),
              //...more parameters here in order to fit your type.
              ce.getSQLparamn() });
      }
  
      ARRAY idArray = new ARRAY(arrayDescriptor, conn, collection);
  
      return idArray;
  
      }
  
  };
  
       MapSqlParameterSource mapIn = new MapSqlParameterSource();
   mapIn.addValue("P_ID_ESCALA", calendario.getEscala().getIdEscala());
       //more simple params here
  
       //Here it is the Oracle ARRAY working properly
   pActualizaDia.declareParameters(new SqlParameter("P_CAMBIOS_EMPRESA",
   OracleTypes.STRUCT, "TTPR_CAMBIO_EMPRESA"));
   mapIn.addValue("P_CAMBIOS_EMPRESA",cambiosEmpresa);
  
       //When executing the procedure it just work :)
       pActualizaDia.execute(mapIn);
       return null;
     }
  </code></pre>
  
  <p>The exception I get sais</p>
  
  <pre><code>java.lang.ClassCastException: $Proxy91 cannot be cast to oracle.jdbc.OracleConnection
  </code></pre>
  
  <p>I've been reading more about this topic and i found that It almost seems like if using Oracle Arrays you also have to cast the connection to be an oracle connection. </p>
  
  <p>However, most Spring jdbc framework classes like SimpleJDBCTemplate and StoredProcedure hide the connection access from you. Do I need to subclass one of those and override a method somewhere to get the dbcp connection and then cast it to an Oracle connection?</p>
  
  <p>Thank you very much.</p>