Hi, In our application, we are using two datasources. One for writing to database and another for reading. Now in Hibernate how can I create the session factory for two datasources and how will I determine which data source has to be used for getting the connection? Normally what will be the approach for such a scenario? Please give your inputs. Thanks in advance. Shanmugavel.
Scott Johnson
Ranch Hand
Joined: Aug 24, 2005
Posts: 518
posted
0
If you have two datasources, you'll need to configure Hibernate to create two SessionFactory objects -- one for each datasource.
Having two SessionFactory objects will have some side effects. Each SessionFactory will have it's own caches which will use more memory. Also, changes written to one SessionFactory will not be reflected in the other SessionFactory's cache causing some stale data problems if you aren't careful.
Kelvin Kelvin
Greenhorn
Joined: Apr 04, 2006
Posts: 1
posted
0
but how can we configure two session-facory in hibernate.cfg.xml?