Skip to content
Philippe Marschall edited this page Oct 8, 2016 · 23 revisions

To call a stored procedure you need to do two things:

  1. create an interface that represents the stored procedures
  2. create and instance of the interface

The interface is a simple POJO interface. If for example you have a salesTax stored procedure that takes a NUMBER and returns a NUMBER the interface declaration would look like this:

public interface TaxProcedures {

  BigDecimal salesTax(BigDecimal subtotal);

}

The instance can be created using only a javax.sql.DataSource

TaxProcedures taxProcedures = ProcedureCallerFactory.build(TaxProcedures.class, dataSource);

Invoking interface methods will then call stored procedures.

taxProcedures.salesTax(new BigDecimal("100.00"));

will actually call the stored procedure.

Deriving Names

We have to derive database names from Java names we differentiate between

  • objects: procedures, packages, schemas
  • parameters

If the Java names do not match the database names then there are different options how we can derive them.

Objects

Parameters

Connection Pooling

We assume the DataSource you provide is a connection pooling DataSource.

Transactions

We don't do transactions. You'll have to do transactions around the stored procedure calls either directly or indirectly through JTA or through Spring or a similar way..

Supported Types

All types that your JDBC driver supports through #getObject and #setObject are supported, we just delegate to the driver. Primitive types are supported and we automatically box and unbox them for you.

Clone this wiki locally