I want two entityManagerFactories but also i have cache manager.
I am getting
I do not know how to define multiple cache manager and assign them to emfs.Code:Another unnamed CacheManager already exists in the same VM
applicationContext.xml:
Code:<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <property name="persistenceUnitName" value="myPU"/> <property name="dataSource" ref="dataSource" /> <property name="jpaVendorAdapter"> <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"> <property name="databasePlatform" value="${database.target}"/> <property name="showSql" value="${database.showSql}" /> </bean> </property> </bean> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"> <property name="driverClass" value="${database.driver}"/> <property name="jdbcUrl" value="${database.url}"/> <property name="user" value="${database.username}"/> <property name="password" value="${database.password}"/> <property name="minPoolSize" value="2"/> <property name="maxPoolSize" value="10"/> <property name="breakAfterAcquireFailure" value="false"/> <property name="acquireRetryAttempts" value="3"/> <property name="idleConnectionTestPeriod" value="300" /> <property name="testConnectionOnCheckout" value="true" /> </bean> <bean id="txManager" class="org.springframework.orm.jpa.JpaTransactionManager"> <property name="entityManagerFactory" ref="entityManagerFactory" /> </bean> <bean id="jamesEntityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <property name="persistenceUnitName" value="jamesPU"/> <property name="dataSource" ref="dataSourceJames" /> <property name="persistenceXmlLocation" value="classpath:META-INF/james-persistence.xml"/> <property name="jpaVendorAdapter"> <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"> <property name="databasePlatform" value="org.hibernate.dialect.MySQL5InnoDBDialect"/> <property name="showSql" value="true" /> </bean> </property> </bean> <bean id="dataSourceJames" class="com.mchange.v2.c3p0.ComboPooledDataSource"> <property name="driverClass" value="com.mysql.jdbc.Driver"/> <property name="jdbcUrl" value="jdbc:mysql://localhost/jamesDb"/> <property name="user" value="root"/> <property name="password" value="root"/> <property name="minPoolSize" value="2"/> <property name="maxPoolSize" value="10"/> <property name="breakAfterAcquireFailure" value="false"/> <property name="acquireRetryAttempts" value="3"/> <property name="idleConnectionTestPeriod" value="300" /> <property name="testConnectionOnCheckout" value="true" /> </bean> <bean id="ehcache" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean" p:shared="true" p:config-location="classpath:ehcache.xml"/> <bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager" > <property name="cacheManager"><ref local="ehcache"></ref></property> </bean> <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />


Reply With Quote