Generating REST web services from PostgreSQL tables

By March 15, 2018Uncategorized

We’ve just released another open source project in github, a humble utility we’ve been using to generate and maintain data intensive rest endpoints that have a CRUD behavior on database tables.

It’s implemented in Java, and it generates:

  • Java Beans for tables.
  • JDBC based Data Access Objects to retrieve and execute commands on the PostgreSQL database.
  • Jersey 2.0 endpoint classes for each table.

The goal was to automate the creation of straight forward endpoints, and to separate data structures, and queries affected by changes in the database in base classes meant to be inherited, and updated regularly as the database evolves. So that, every time you make a change in the database, you just run the generation process and it updates all your related code.

All the generation is driven by templates files, with some ugly tokens for dynamically replacing content and at times for required pre processing of conditional logic.

The generation is based on metadata queried from the PostgreSQL database, but it could be extended to support other relational sources.

It generates Java code, but we are thinking about moving to node.js REST endpoint generation, in the near future. Suggestions and contributions in this sense are welcomed.

Check it out, and please do provide feedback!

Leave a Reply