Hi there,
I need to set up multiple Sessionfactories in my app, now I'm facing a problem. I can't use the 2nd level cache at the moment because only the cache from the first factory is returned. Providing a hibernate.cache.region_prefix
would solve the problem I guess. How can I supply for each factory a own region per Spring XML config?
applicationContext.xml
<bean id="hibernateProperties"
class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="locations">
<list>
<value>/WEB-INF/hibernate/hibernate.properties</value>
</list>
</property>
</bean>
<bean id="cacheRegionFactory" class="org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge">
<constructor-arg>
<props>
<prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
</props>
</constructor-arg>
</bean>
<bean id="factory_1"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="db2Datasource" />
<property name="mappingDirectoryLocations" value="classpath:de/ac/hibernate" />
<property name="hibernateProperties" ref="hibernateProperties" />
<property name="cacheRegionFactory" ref="cacheRegionFactory" />
</bean>
<bean id="factory_2"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="db2Datasource2" />
<property name="mappingDirectoryLocations" value="classpath:de/ac/hibernate" />
<property name="hibernateProperties" ref="hibernateProperties" />
<property name="cacheRegionFactory" ref="cacheRegionFactory" />
</bean>
hibernate.properties
hibernate.dialect=org.hibernate.dialect.DB2400Dialect
hibernate.connection.autocommit=false
hibernate.connection.charset=UTF-8
hibernate.show_sql=false
hibernate.cache.use_second_level_cache=false
hibernate.generate_statistics=false
I don't want to provide the properties per sessionfactory is this even possible? I'm using Spring 3.0.2
, Hibernate 3.5