Skip to content

Oracle Packages

Philippe Marschall edited this page Mar 26, 2017 · 5 revisions

Oracle packages can contain both procedures and functions. We recommend creating one interface per Oracle package.

public interface Taxes {

  BigDecimal salesTax(BigDecimal subtotal);

  BigDecimal stateTax(BigDecimal subtotal);

}

If we assume both procedures are in the same package called p_taxes we can either use a naming strategy or annotate the interface with @Namespace.

If we annotate the interface

@Namespace("p_taxes")
public interface Taxes {

  BigDecimal salesTax(BigDecimal subtotal);

  BigDecimal stateTax(BigDecimal subtotal);

}

we enable package support with

ProcedureCallerFactory.of(Taxes.clas, dataSource)
    .withNamespace()
    .build();

If we decided to go with a NamingStrategy instead of the annotation we enable package support and configure the NamingStrategy with

ProcedureCallerFactory.of(Taxes.clas, dataSource)
    .withNamespaceNamingStrategy(NamingStrategy.lowerCase().thenPrefix("p_"))
    .build();