• Post Reply Bookmark Topic Watch Topic
  • New Topic

Load Hibernate configuration from a different file  RSS feed

Ainar Martin
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!