This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Load Hibernate configuration from a different file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Load Hibernate configuration from a different file" Watch "Load Hibernate configuration from a different file" New topic
Author

Load Hibernate configuration from a different file

Ainar Martin
Greenhorn

Joined: Mar 22, 2011
Posts: 11
Hello,
I need to read the Hibernate configuration properties from a file name different that hibernate.cfg.xml

Following code works but is deprecated:

SessionFactory sessionFactory=new Configuration().configure("hibernate.content.cfg.xml").buildSessionFactory();

But when I try to use the new configuration method:

serviceRegistry = new ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry();
sessionFactory = configuration.buildSessionFactory(serviceRegistry);
....

it doesn't work.

How should I get Hibernate to read a different configuration file?

Thank you.
 
wood burning stoves
 
subject: Load Hibernate configuration from a different file
 
Similar Threads
CDI question
Problem with Hibernate and Oracle
Hibernate configuration issue: connection provider or hibernate.dialect issue
Mapping issue in hibernate.cfg.xml
org.hibernate.InvalidMappingException