File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 Soft Skills this week in the Jobs Discussion 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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Load Hibernate configuration from a different file