hibernate, server specific configuration
we have two different environments (test and production), each with it's own database connection.
The database connection is configured in the hibernate.cfg.xml, together with the mappings etc. The hibernate.cfg.xml is part of the application - hence we cannot configure the database connection depending on the environment.
So we need some kind of configuration outside the applicatio开发者_运维技巧n.
What is the best way for handling server specific database configurations with hibernate?
U can configure using annotations. below is exa
sessionFactory = new AnnotationConfiguration()
.addPackage("test.animals") //the fully qualified package name
.addAnnotatedClass(Flight.class)
.addAnnotatedClass(Sky.class)
.addAnnotatedClass(Person.class)
.addAnnotatedClass(Dog.class)
.addResource("test/animals/orm.xml")
.configure()
.buildSessionFactory();
精彩评论