Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate Configuration help!

 
Joe Harry
Ranch Hand
Posts: 10106
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can we have two cfg.xml files for the same project?? What effect would that make? The below is from the Hibernate Documentation.

With the XML configuration, starting Hibernate is then as simple as
SessionFactory sf = new Configuration().configure().buildSessionFactory();

You can pick a different XML configuration file using
SessionFactory sf = new Configuration()
.configure("catdb.cfg.xml")
.buildSessionFactory();
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. With two configurations you can have two different SessionFactories.
[ July 05, 2007: Message edited by: Paul Sturrock ]
 
Joe Harry
Ranch Hand
Posts: 10106
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But what would that mean to my application using two sessionfactories with each connecting to different database. So that means I can connect to two different databases imagining I have configured them appropriately in the hibernate1.cfg.xml file (with properties set to connect to oracle db) and hibernate2.cfg.xml file (with properties set to connect to mysql db)?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, two SessionFactories would enable your application to persist to two differernt databases.
 
Joe Harry
Ranch Hand
Posts: 10106
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic