Announcement Announcement Module
Collapse
No announcement yet.
How can use multiple persistence-unit with spring data jpa Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How can use multiple persistence-unit with spring data jpa

    I am using

    <dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-jpa</artifactId>
    <version>1.0.0.M1</version>
    </dependency>

    I want to know how to tell <jpa:repositories> to use SharedEntityManagerBean?
    I have multiple jar's with different persistence units
    and at the time of autowire repo's it would fail saying "No unique bean EntityManagerFactory" : Exception given below
    ------------------------------------------------
    org.springframework.beans.factory.NoSuchBeanDefini tionException: No unique bean of type [javax.persistence.EntityManagerFactory] is defined: expected single bean but found 2
    at org.springframework.orm.jpa.support.PersistenceAnn otationBeanPostProcessor.findDefaultEntityManagerF actory(PersistenceAnnotationBeanPostProcessor.java :536)
    at org.springframework.orm.jpa.support.PersistenceAnn otationBeanPostProcessor.findEntityManagerFactory( PersistenceAnnotationBeanPostProcessor.java:495)

  • #2
    There's an entity-manager-factory-ref attribute at the repositories element that allows you to explicitly wire the EMF to all repositories discovered by that element to work with. Unfortunately the documentation doesn't seem to mention that attribute so I created DATADOC-91 [0].

    [0] https://jira.springsource.org/browse/DATAJPA-91

    Comment

    Working...
    X