I just use multiple database instances, but that's a simple measure if you have multiple machines to play with. That way only the .cfg file needs to change to specify the host on which the database resides.
You could potentially do the same but with each database instance running on a different port, if it is supported by your DB (not actually tried this).
The last possibility is to recreate the hbm.xml files from templates during initialisation, and before the first Session is created. If you use a utility class to contain convenience session handling (like HibernateUtil in the example code), create a static initialiser that reads the source .hbm.xml files and replaces some predetermined token, such as $SCHEMA$ with the actual schema for the current config, then write these files wherever hibernate is expecting to find them.
Performance cost wouldn't be too high either as its a one shot mechanism on startup.
|