Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You can pass an Oracle Object that has a Blob to SimpleJdbcCall by following these steps:

  1. Define a custom class that mirrors the Oracle Object you are trying to pass. For example, if your Oracle Object is named "MYOBJECT" and has a property "MYBLOB", you can define a class like this:
public class MyObject {
   private Blob myBlob;

   public Blob getMyBlob() {
      return myBlob;
   }

   public void setMyBlob(Blob myBlob) {
      this.myBlob = myBlob;
   }
}
  1. Create an instance of this class and set the Blob property appropriately:
MyObject obj = new MyObject();
obj.setMyBlob(myBlob);
  1. Create an instance of SimpleJdbcCall and set the appropriate parameters:
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.