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.