Forums Register Login

only one SessionFactory Object per application right?

+Pie Number of slices to send: Send
Session Factory is thread safe so there is only one object of sessionFactory is available through out the run right.

thanks
+Pie Number of slices to send: Send
 

are you talking about , hibernate session factory ?

 
+Pie Number of slices to send: Send
yes
my doubt is can we have only one session factory object or as many as we like?
+Pie Number of slices to send: Send
i am not sure.since i am newbie to hibernate. but i read that SessionFactory is a Singleton and it create Session in heavyweight process
+Pie Number of slices to send: Send
Normally it would be one SessionFactory per DataSource. Your application may have more than one DataSource so you may have more than one SessionFactory in that instance. But you would not want to create a SessionFactory more than once in an application
+Pie Number of slices to send: Send
The SessionFactory is a pretty resource heavy component, so you don't want to create multitudes of them. As was stated, one per datasource, or one per database if you have multiple databases, is usually when you have multiples. The Hiberante Session on the other hand is very resource friendly, and you can create lots of them!

-Cameron McKenzie
+Pie Number of slices to send: Send
Session factory object is implemented using the singleton design pattern. Instances of SessionFactory are thread-safe and typically shared throughout an application. As these objects are heavy weight because they contains the connection information, hibernate configuration information and mapping files location path. So creating number of instances will make our application heavy weight. But the session objects are not thread safe. Tag line is - SessionFactory objects are one per application and Session objects are one per client.
+Pie Number of slices to send: Send
 

imam tunduru wrote:Session factory object is implemented using the singleton design pattern.


No, its not.
Grow a forest with seedballs and this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 6753 times.
Similar Threads
hibernate.cfg.xml required in version 2.x?
How internally works
Doubt in Garbage Collection
More than one connection in the Hibernate
JNDI error message
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 04:04:26.