我今天有同样的问题。解决了以下问题:
首先,我将参数unitName添加到@PersistenceContext到两个实体管理器属性:
@PersistenceContext(unitName="appPU")@Qualifier(value = "appEntityManagerFactory")private EntityManager appEntityManager;@PersistenceContext(unitName="managerPU")@Qualifier(value = "managerEntityManagerFactory")private EntityManager managerEntityManager;
在我的配置文件中,我向bean定义添加了一个属性persistenceUnitName:
<bean id="appEntityManagerFactory" > <property name="dataSource" ref="dataSource1" /> <property name="persistenceUnitName" value="appPU" /> <property name="packagesToScan" value="br.com.app.domain" /> ...</bean><bean id="managerEntityManagerFactory" > <property name="dataSource" ref="dataSource2" /> <property name="persistenceUnitName" value="managerPU" /> <property name="packagesToScan" value="br.com.app.domain" /> ...</bean>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)