1 | initial version |
You can pass an Oracle Object that has a Blob to SimpleJdbcCall by following these steps:
public class MyObject {
private Blob myBlob;
public Blob getMyBlob() {
return myBlob;
}
public void setMyBlob(Blob myBlob) {
this.myBlob = myBlob;
}
}
MyObject obj = new MyObject();
obj.setMyBlob(myBlob);
SimpleJdbcCall jdbcCall = new SimpleJdbcCall(jdbcTemplate)
.withProcedureName("MY_PROCEDURE")
.declareParameters(
new SqlParameter("MY_OBJECT", OracleTypes.STRUCT, "MY_OBJECT_TYPE", new SqlUserDefinedTypeValue<MyObject>("MY_OBJECT_TYPE", obj))
);
In this example, "MYPROCEDURE" is the name of the stored procedure you want to call, "MYOBJECTTYPE" is the name of the Oracle Object type, and "MYOBJECT" is the parameter name. The last parameter sets the value of the parameter to an instance of the MyObject class you created earlier.