ernst_pluess wrote:
You have to use 2 configuration xml files. One for each DB.
HTH
Ernst
To expand on this, this means you must explicitly load the config files and not rely on the default loading of hibernate.cfg.xml (you could do it that way but it will be messy: avoid messy default behaviour by not having a hibernate.cfg.xml anywhere on your classpath).
Something like this would do the job (I use this to dynamically switch a maintenance tool I've written between multiple databases: one uses MySQL and is my test db, the other two are SQLServer instances).
String configFilename = "/aconfigfile.cfg.xml";
Configuration config = new Configuration().configure(getClass().getResource(configFilename));
You'd need one Configuration for each data source and use them to create SessionFactorys etc. I have no idea how you'd get hibernate to enlist in a distributed transaction so I hope you don't need to do updates to both databases at the same time :-)