How to connect to different databases (development/test/production) transparently with hibernate

前端 未结 4 1659
广开言路
广开言路 2021-01-01 01:35

I have several different databases for different environments to connect my application to. These are constant per installation but differ between them. In other words there

4条回答
  •  醉酒成梦
    2021-01-01 02:14

    You can bundle the hibernate.cfg.xml in a .jar or you could use a JPA (persistence.xml) approach instead which allows you to have different "persistence units" that you can then choose based on any variable you'd like (a properties file in your home for example). See http://docs.jboss.org/hibernate/entitymanager/3.6/reference/en/html/configuration.html#setup-configuration-packaging for an example of a persistence.xml.

提交回复
热议问题