mercredi 1 avril 2015

Multiple database support using hibernate

I am working on an application that currently supports MSSQL and MYSQL and now we need to make it compatible with Oracle and Postgresql too. We have a strong dependency on the Id generated for the records as we use the same Id to generate some logical identifiers for the records.Therefore we want each of the tables to have it's own sequence such that each new record has a new logical identifier which is in the sequence n,n+1,n+2 and the logical identifiers will therefore be XYn,XY(n+1),XY(n+2).


Using the generation strategy AUTO for the Id worked with both MSSQL and MYSQL but doesn't work with Oracle or Postgresql as the generation strategy AUTO ultimately maps to SEQUENCE for these databases. I need to maintain a common code for all these databases and cannot afford to make any database changes. Please suggest some ways to get this done.


Aucun commentaire:

Enregistrer un commentaire