-
Notifications
You must be signed in to change notification settings - Fork 367
Description
Krzysztof Lorencki opened DATAJDBC-49 and commented
I create two simple Oracle types:
create or replace type MY_SIMPLE_TYPE force as object
(uuid varchar2(32),
uuid_type varchar2(16)
);
CREATE OR REPLACE TYPE MY_SIMPLE_TYPE_ARRAY AS TABLE OF MY_SIMPLE_TYPE;
Next I create a package:
create or replace package xxx
is
function GetList return my_simple_type_array;
PROCEDURE SETLIST(X MY_SIMPLE_TYPE_ARRAY);
end;
with following body:
create or replace package body XXX
is
function GetList return my_simple_type_array
is
begin
return my_simple_type_array(my_simple_type('1234567890','X'),my_simple_type('ABCDEF','Y'));
end;
procedure SETLIST(x my_simple_type_array)
is
begin
raise_application_error(-20111,x.count);
end;
end;
Now I'll try to execute function GetList. I create a wrapper for my Oracle type:
public class My_simple_type_wrapper implements SQLData {
public My_simple_type_wrapper(String uuid, String type) {
this.uuid = uuid;
this.type = type;
}
public My_simple_type_wrapper() {
}
private String uuid;
private String type;
public String getUuid() {
return uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getSQLTypeName() throws SQLException {
return "MY_SIMPLE_TYPE";
}
public void readSQL(SQLInput stream, String typeName) throws SQLException {
setUuid(stream.readString());
setType(stream.readString());
}
public void writeSQL(SQLOutput stream) throws SQLException {
stream.writeString(uuid);
stream.writeString(this.type);
}
}
And try to execute my function:
Map in = Collections.emptyMap();
My_simple_type_wrapper[] executeFunction = new SimpleJdbcCall(this.getJdbcTemplate())
.withCatalogName("XXX")
.withFunctionName("GetList")
.withoutProcedureColumnMetaDataAccess()
.declareParameters(new
SqlOutParameter("return",Types.ARRAY,"MY_SIMPLE_TYPE_ARRAY", new
SqlReturnArray()))
.executeFunction(My_simple_type_wrapper[].class,in);
After execution I get following error:
[Ljava.lang.Object; cannot be cast to [My_simple_type_wrapper
It seems that that is some casting problem. executeFunction returns array of object (STRUCT object in fact instead of my My_simple_type_wrapper class). Same code works perfect for simple type like:
CREATE OR REPLACE TYPE actor_name_array AS table OF VARCHAR2(50);
It returns array of String as excepted.It seems that you're not able to find my wrapper class when output parameter is used. There is no problem with input parameters - works as excepted with My_simple_type_wrapper
Affects: Ext 1.0 RELEASE