I have Oracle objects defined as follows:
create or replace TYPE "FILEIITEM_OBJ" AS OBJECT
(
FILENAME VARCHAR2(100)
,CONTENT BLOB
);
and
create or replace TYPE "FILEITEM_COLL" IS TABLE OF FILEITEM_OBJ;
I need to call a procedure ("requestWithBlob") via ```SimpleJdbcCall`` that accepts the FILEITEM_COLL as a parameter ("fileitem_coll_p").
So, I try this:
public class FileInfo {
private String filename;
private Blob content;
// setters and getters
}
and
public String requestWithBlob(List<FileInfo> files) {
// create a SimpleJdbcCall
SimpleJdbcCall call = new SimpleJdbcCall(this.jdbcTemplate).withCatalogName("CATALOG")
.withProcedureName("requestWithBlob").withoutProcedureColumnMetaDataAccess()
.declareParameters(
new SqlParameter("fileitem_coll_p", OracleTypes.ARRAY, "FILEIITEM_COLL"),
// out parameter
}
// create a MapSqlParameterSource
SqlParameterSource source = new MapSqlParameterSource()
.addValue("fileitem_coll_p", fileItems.toArray(FileItem[]::new), OracleTypes.ARRAY, "FILEITEM_COLL");
// execute the call
Map<String, Object> result = call.execute(source);
Unfortunately, this comes back with an error:
java.sql.SQLException: Fail to convert to internal representation: [Lcom.jason.repository.FileItem;@440d1e2f
at oracle.sql.ARRAY.toARRAY(ARRAY.java:309) ~[ojdbc8-21.5.0.0.jar:21.5.0.0.0]
Can anyone help?