We are using the old style (proprietary hibernate - not JPA ) using .hbm.xml files. The plan is to eventually go to JPA the next release but not right now.
We have a product that ships where the customer may choose any one of four databases:
PostgreSQL MySQL Oracle SQL Server
Both MySQL and SQL Server have database constructs that support self-incrementing primary keys. For PostgreSQL and Oracle we are using sequences.
In the .hbm.xml file for the primary sequence, we specify 'native' and for the PostgreSQL / Oracle .hbm.xml files we use the named sequence.
We have not found an easy way to maintain two sets of .hbm.xml files and I wanted to get some suggestions.
My ideal solution would be to not/ever check in any .hbm.xml file but have it generated during the build from a DB the build can connect to. We use maven so would setup two profiles: 1) MySQL / SQL Server 2) Oracle / PostgreSQL
and have the correct entry created there for the sequence. I am not sure if this can be done and if there is a maven plugin that will do this, and do not even know if .hbm.xml files can be generated from a model alone. The only way to do this would be to have some sort of mapping file that would have hard coded the name of the sequence per table.
At any rate, if there is an easier way to manage multiple DB's like this and manage multiple .hbm.xml files (per table), please let me know.
|