Get your CodeRanch badge!*
The moose likes Object Relational Mapping and the fly likes  Two session-factory in one hibernate.cfg.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark " Two session-factory in one hibernate.cfg.xml" Watch " Two session-factory in one hibernate.cfg.xml" New topic
Author

Two session-factory in one hibernate.cfg.xml

himaunshu shah
Greenhorn

Joined: Sep 14, 2004
Posts: 1
Hi,

I want to access two databases. I know this can be achieved by creating two
XML configuration files and creating two Configuration and SessionFactory objects in the application.

But is it possible to have two session-factoy tags in one hibernate.cfg.xml? If yes, then what should be the format of the cfg.cml and how to access two SessionFactory objects.

Thanks in advance.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Have a look at the DTD - only one session-factory element is allowed in a hibernate-configuration. So you'll need two config files.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Two session-factory in one hibernate.cfg.xml
 
Similar Threads
How internally works
Collection Mapping
Best Method for the Singleton Design Pattern
having two hibernate.cfg.xml on the same project
Multiple Database Connections with Hibernate 3