• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

More than SessionFactory in single hibernate.cfg.xml?

 
raja selva
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can we have more than one session-factory in single hibernate.cfg.cml file as below code? If it is yes. How?

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<!-- Generated by MyEclipse Hibernate Tools. -->
<hibernate-configuration>
<session-factory name="mysql">
.
.
</session-factory>

<session-factory name="HSQLDB">
.
.
</session-factory>
</hibernate-configuration>
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, as the DTD states.

You can have more then one SessionFactory in an application, which would be the configuration you would need to connect to more than one database.
 
raja selva
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your quick reply.

Suppose I need to connect more then one database in my application, we go for more hibernate.cfg.xml in my CLASSPATH right?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic