Announcement Announcement Module
Collapse
No announcement yet.
Multiple datasources and thus multiple sessionFactories Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Multiple datasources and thus multiple sessionFactories

    We are using 2 datasources and therefore defined 2 different sessionFactories in the application context files.
    Problem is that OpenSessionInViewFilter can only fetch 1 sessionFactory.

    How can we solve this within the logic of the framework ?
    Subclass OpenSessionInViewFilter so that it can fetch a list of sessionFactories.

    Edwin

  • #2
    You could configure two filters. When OpenSessionInViewFilter fires, it creates a new Hibernate session (if none can be found) and registers it within TransactionSynchronizationManager using sessionFactory as the key. Since you are using two sessionFactories, you can use two Hibernate Session at the same time.

    HTH

    Comment

    Working...
    X