• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

More than one connection in the Hibernate

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Using the Session.close() method?

 
Omar Al Kababji
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic