Is it possible to have two persistence units, one with Hibernate to work with some entities and another with EclipseLink to work with other entities in Spring framework?
Asked
Active
Viewed 356 times
0
-
Thank you for answer, do you have any example or configuration code snippet for this case? – iceDice Mar 04 '15 at 08:38
1 Answers
0
The following should work:
<bean id="schema1EM" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
...
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
...
</bean>
</property>
<property name="packagesToScan" value="org.example.domain.schema1"/>
</bean>
<bean id="schema2EM" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
...
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter">
...
</bean>
</property>
<property name="packagesToScan" value="org.example.domain.schema2"/>
</bean>
<jpa:repositories base-package="org.example.data.schema1" entity-manager-factory-ref="schema1EM"/>
<jpa:repositories base-package="org.example.data.schema2" entity-manager-factory-ref="schema2EM"/>
schema1EM
will be assigned to all repositories declared under the package org.example.data.schema1
and schema2EM
will be assigned to those under org.example.data.schema2
. You will have to segregated the domain classes and repository interfaces by packages so that the Spring auto-wiring can work.

manish
- 19,695
- 5
- 67
- 91