This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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.
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.