0

My application is interacting with two separate database. I want to inject session factory with spring.net as usually. when I am creating 2 session factory with two separate dbProviders , it is showing error. Is there any way to accomplish this task ?

Kavi
  • 176
  • 1
  • 12
  • Please clarify your question a bit. For instance add the error message and tell us what you have tried. – Marijn Aug 28 '12 at 06:30

2 Answers2

1

You have to use a DelegatingLocalSessionFactory object, available for Spring.NET 1.3.1 and up. According to the docs:

due to variations in the NHibernate project's ISessionFactory API, this approach is only supported under NHibernate 2.1.2 and NHibernate 3.0

I'm not sure about NHibernate > 3.0.

Marijn
  • 10,367
  • 5
  • 59
  • 80
  • I think this is for if we have same database schema and changing the connection on some parameter. But in my case the database are completely separate. I have 2 separate DAL and service layer for both the databases. thoughts ? – Kavi Aug 27 '12 at 10:12
  • Ah, I missed that from your question. You are absolutely right, a `DelegatingLocalSessionFactory` assumes both database use the same mappings. – Marijn Aug 28 '12 at 06:29
0

I solved it by creating my own transaction API with Spring AOP.

Kavi
  • 176
  • 1
  • 12