AF
HomeTagSubmit NotesAsk AnythingLoginSubscribe Us
AF
1. Feel Free to ask and submit anything on Anyforum.in and get satisfactory answer
2. Registration is not compulsory, you can directly login via google or facebook
3. Our Experts are looking for yours ?.



hibernate-basics: How can we load hibernate configuration file from different directory?

Can we put hibernate.cfg.xml file other than src folder? If yes then how can we load it?

hibernate x 23
basics x 171
Posted On : 2014-10-11 12:25:21.0
profile Garima Gupta - anyforum.in Garima Gupta
596129554552
up-rate
3
down-rate

Answers


Yes, you can use different path other than src. You can change the default Hibernate´s SessionFactory class by passing your "hibernate.cfg.xml" file path as an argument into the configure() method:

SessionFactory sessionFactory =
new Configuration().configure("/in/anyforum/persistence/hibernate.cfg.xml").buildSessionFactory();
return sessionFactory;

Posted On : 2014-10-11 13:36:30
Satisfied : 1 Yes  0 No
profile Rishi Kumar - anyforum.in Rishi Kumar
523188245674
Reply This Thread
up-rate
5
down-rate



Post Answer
Please Login First to Post Answer: Login login with facebook - anyforum.in