We have a server-side application (in JAVA, communicates via web services) that accesses a database. If we wish to sell just the application to a customer, so that he can use his own choice of database (RDBMS for now), how can I design the application to work with any database developed as per some spec ? I have considered JPA for now but still not sure about all its features. Imagine if Facebook were to sell their core logic, independent of database so that buyer can implement any database and plug this to facebook logic.

  • Make the application open source. Then they can change it any way they see fit as long as it doesn't break your licensing agreement.
    – JeffO
    May 2, 2018 at 19:34

1 Answer 1


JPA is a specification - you would want to leverage an implementation of it. There are a large number of Object Relational Mappings (ORMs) that are database agnostic most of which provide JPA implementation - Hibernate, SpringData, EclipseLink (used to be TopLink), Apache Cayenne.

If you want to work directly at the SQL layer rather than through a JPA then you should write your SQL the ANSI SQL specification, which most databases support. If you go this route I would recommend encapsulating your SQL and providing a mechanism for DB specific overrides of the SQL, to provide the option for tuning SQL for a specific DB and leveraging DB specific syntax and features.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.