I'm running Spring 3.0. I have an application that needs to connect to 130 data sources. It will read data from any n number of those data sources.
Rather than having to support a static Spring configuration for each of these data sources; I have chosen to implement a factory that will create a persistence manager object for each data source. I simply converted the static implementation into a dynamic implementation.
The LocalSessionFactoryBean does not appear to work outside of the Spring application context container. Here is the code:
The problem is that newFactory.getObject() returns null. There are no exceptions thrown.
SpringHibernateLocalSessionFactoryPropertyHolder curPropertyHolder = entry.getValue();
org.springframework.orm.hibernate3.LocalSessionFactoryBean newFactory = new org.springframework.orm.hibernate3.LocalSessionFactoryBean();
newFactory.setMappingResources( curPropertyHolder.getMappingResources() );
newFactory.setHibernateProperties( curPropertyHolder.getHibernateProperties() );
newFactory.setDataSource( dataSource );
SessionFactory sessionFactory = newFactory.getObject();
org.springframework.orm.hibernate3.HibernateTransactionManager transactionManager = new org.springframework.orm.hibernate3.HibernateTransactionManager();
transactionManager.setSessionFactory( sessionFactory );
Is LocalSessionFactoryBean designed to work in this manner or must it be instantiated from the container? I'm thinking that I need 1 instance per persistence manager, to remain consistent with the static implementation. That is why I am not injecting the instance.
If I'm on the wrong track; what is the recommended solution?
Thanks in advance for your assistance...