Stored Procedure Proxy

Proxies through which to call stored procedures.

License

License

MIT
GroupId

GroupId

com.github.marschall
ArtifactId

ArtifactId

stored-procedure-proxy
Last Version

Last Version

0.12.0
Release Date

Release Date

Type

Type

jar
Description

Description

Stored Procedure Proxy
Proxies through which to call stored procedures.
Project URL

Project URL

https://github.com/marschall/stored-procedure-proxy
Source Code Management

Source Code Management

https://github.com/marschall/stored-procedure-proxy

Download stored-procedure-proxy

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.marschall/stored-procedure-proxy/ -->
<dependency>
    <groupId>com.github.marschall</groupId>
    <artifactId>stored-procedure-proxy</artifactId>
    <version>0.12.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.marschall/stored-procedure-proxy/
implementation 'com.github.marschall:stored-procedure-proxy:0.12.0'
// https://jarcasting.com/artifacts/com.github.marschall/stored-procedure-proxy/
implementation ("com.github.marschall:stored-procedure-proxy:0.12.0")
'com.github.marschall:stored-procedure-proxy:jar:0.12.0'
<dependency org="com.github.marschall" name="stored-procedure-proxy" rev="0.12.0">
  <artifact name="stored-procedure-proxy" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.marschall', module='stored-procedure-proxy', version='0.12.0')
)
libraryDependencies += "com.github.marschall" % "stored-procedure-proxy" % "0.12.0"
[com.github.marschall/stored-procedure-proxy "0.12.0"]

Dependencies

compile (4)

Group / Artifact Type Version
org.springframework : spring-core Optional jar
org.springframework : spring-jdbc Optional jar
org.springframework : spring-tx Optional jar
org.postgresql : postgresql Optional jar 42.2.20

test (21)

Group / Artifact Type Version
org.springframework : spring-context jar
org.springframework : spring-test jar
com.h2database : h2 jar 1.4.200
org.hsqldb : hsqldb jar 2.5.1
org.apache.derby : derby jar 10.15.1.3
org.apache.derby : derbyshared jar 10.15.1.3
org.apache.derby : derbytools jar 10.15.1.3
org.firebirdsql.jdbc : jaybird jar 4.0.3.java8
org.mockito : mockito-core jar 3.9.0
com.oracle.database.jdbc : ojdbc8 jar
com.ibm.db2 : jcc jar 11.5.5.0
mysql : mysql-connector-java jar 8.0.24
org.mariadb.jdbc : mariadb-java-client jar 2.7.2
com.microsoft.sqlserver : mssql-jdbc jar 9.2.1.jre8
org.junit.jupiter : junit-jupiter-api jar
org.junit.jupiter : junit-jupiter-params jar
org.junit.jupiter : junit-jupiter-engine jar
org.hamcrest : hamcrest-junit jar 2.0.0.0
org.apache.logging.log4j : log4j-core jar
org.apache.logging.log4j : log4j-slf4j-impl jar
org.apache.logging.log4j : log4j-jcl jar

Project Modules

There are no modules declared in this project.

Stored Procedure Proxy Maven Central Javadocs Build Status license

A more convenient and type safe way to call stored procedures from Java.

This project allows you to define a Java interface method for every stored procedure you want to call. Then it creates a dynamic instance of that interface that calls the stored procedure whenever you call the method.

Simply create an interface that represents the stored procedures you want to call.

public interface TaxProcedures {

  BigDecimal salesTax(BigDecimal subtotal);

}

Then create an instance using only a javax.sql.DataSource

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

Invoking interface methods will then call stored procedure.

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

will actually call the stored procedure.

Check out the wiki for more information.

The project has no runtime dependencies and is a single JAR weighting 100 kB.

<dependency>
  <groupId>com.github.marschall</groupId>
  <artifactId>stored-procedure-proxy</artifactId>
  <version>0.12.0</version>
</dependency>

What problem does this project solve?

Calling simple stored procedures in JDBC or JPA is unnecessarily cumbersome and not type safe. While this may be required in rare cases in common cases this can be solved much easier. None of the common data access layers solve this issue:

  • While spring-jdbc offers many ways to call a stored procedure all of them require the registration of SqlParameter objects. The options are:
  • Spring Data JPA offers two ways
    • the first is hardly an improvement since it still needs a @NamedStoredProcedureQuery
    • the second is quite nice, we take inspiration from this approach and add more flexibility
  • jOOQ offers stored procedure support in a way that is similar to this project, in addition it supports many more features and can generate classes from a database schema. The only down sides are that it requires passing a configuration object (for now) and Oracle support is commercial.
  • jDBI falls back to manual parameter registration for out parameters as well.
  • Ebean falls back to manual parameter registration for out parameters as well.
  • Querydsl has no support at all
  • Sql2o seems to have no support at all
  • spwrap is similar in spirit but requires more annotations and is currently a bit less flexible

While they all have their use case none of them fitted our needs.

Versions

Version
0.12.0
0.11.0
0.10.1
0.10.0
0.9.0
0.8.3
0.8.2
0.8.1
0.8.0
0.7.0
0.6.0
0.5.0
0.4.0
0.3.0
0.2.0
0.1.1
0.1.0