mindiga
mindiga

Reputation: 539

How to expose the complete database schema as an OData service

I am starting a new project and my company is now using only OData REST services for internal data exchange, while retiring all general-purpose REST services developed before. The legacy systems that I am integrating run on many databases such as MS SQL, Oracle, DB2, MySql, Progres, Informix and HANA.

How to expose the complete DB SQL schema as OData REST services in a generic way, instead of having to build OData services with Apache Spring and Olingo, one service at a time per table.

Otherwise, I would need to build a single generic REST OData service, that will automatically expose data from all these databases, by reading the table and column metadata through the JDBC driver and using it to define OData attributes.

Upvotes: 2

Views: 2044

Answers (2)

Werner Daehn
Werner Daehn

Reputation: 635

I used oLingo for that as well. First problem is how many classes must be implemented and second question is should it be one endpoint with many entities or one endpoint per table? Both have pros and cons.

After two years of oLingo I finally decided to build something native using JAXB. https://github.com/rtdi/JDBCoData

Upvotes: 0

Shiva
Shiva

Reputation: 6885

I am afraid there is no plug and play solutions available for exposing all the database to OData in the eco-system, you might have two options to solve the problem

  1. Create a custom OData Processor that uses the approach you have mentioned, i.e. it makes a JDBC connection, generates the SQL Strings and implementations all the OData functionality like readEntitySet,writeEntitySet and so on. In my opinion this is eminency powerful but at the same time very time consuming especially when you start implementing the OData Operations file $filter
  2. The other alternative approach is to use OData Jpa Processor here you get the OData APIs implemented, you still have to define the JPAModels though, You can use eclipse tooling to generate the JPA Model files from Database tables as documented here

Upvotes: 1

Related Questions