-
Notifications
You must be signed in to change notification settings - Fork 2
Home
To call a stored procedure you need to do two things:
- create an interface that represents the stored procedures
- 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.
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.
We assume the DataSource you provide is a connection pooling DataSource.
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..
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.
-
Usage
-
Integration