Giter Club home page Giter Club logo

stored-procedure-proxy's Introduction

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.11.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.

stored-procedure-proxy's People

Contributors

marschall avatar taregger avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.