• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

More than one connection in the Hibernate

 
ramzi ghaith
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

The question is how i can use more than one SessionFactory in the Hibernate 3.0 (it will be in the same hibernate.cfg.cml or i should use more than one hibernate.cfg.cml ???)

And how i can handle the sessions issue.

Regards,
Ramzi
 
Omar Al Kababji
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can have only one sessionFactory in the hibernate.cfg.xml so you will have to write another configuration file.
 
ramzi ghaith
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Omar for your reply ...

I used another hibernate configuration file and the connection with more than one database done, but the issue is how i can close the two sessions ??? because i face a too many connections ???


Regards,
Ramzi
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using the Session.close() method?

 
Omar Al Kababji
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nothing would be changing in your situation, you will be having to session factory classes

SessionFactory1
SessionFactory2

the only thing you need is if you are getting session's using openNewSession() you will have to close it manually using sessin.close(); while if you are getting session's using the getCurrentSession() message then you don't have to worry. note that the number of SessionFactories doesn't have to do anything with how session's are managed.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic