Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Can we Write more than 2 hibernate.cfg.xml's?

 
Barry Van
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Can we Write more than 2 hibernate.cfg.xml's?
If yes, How to add sessions? please give with exampls?
 
Barry Van
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This code rite? please check..if wrong.. how can we use 2 cfg.xml's?

Configuration cfg = new Configuration();
cfg.addFile("hibernate.cfg.xml");
cfg.addFile("hibernate2.cfg.xml");

sessionFactory = cfg.buildSessionFactory();
 
Barry Van
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Please any one resolve the above Issues..
 
Reehan Lalkhanwar
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think that is possible.
Look at the below code. Hope that might be of some help.
 
Barry Van
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Please check this code.. Is it write..?
Is it Possible to use morethan one cfg xmls?

Configuration cfg = new Configuration();
cfg.configure("hibernate1.cfg.xml");
cfg.configure("hibernate2.cfg.xml");
// sessionFactory = new Configuration().configure().buildSessionFactory();
sessionFactory = cfg.buildSessionFactory();
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!