Announcement Announcement Module
No announcement yet.
LocalContainerEntityManagerFactoryBean automatic discovery of JPA provider Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • LocalContainerEntityManagerFactoryBean automatic discovery of JPA provider

    I would like LocalContainerEntityManagerFactoryBean to automatically discover my JPA provider just like javax.persistence.Persistence.createEntityManagerF actory("pu-name") does so that when switching between JPA providers like Hibernate and EclipseLink I need not edit the <provider> element META-INF/persistence.xml.

    But when I try to create a LocalContainerEntityManagerFactoryBean without specifying a <provider> in persistence.xml I get the very informative error message:

    "No PersistenceProvider specified in EntityManagerFactory configuration, and chosen PersistenceUnitInfo does not specify a provider class name either"

    Does Spring provide any kind of EntityManagerFactoryBean that automatically detects the JPA provider at runtime (by classpath scanning or other means ...)?

  • #2
    The reference manual says LocalEntityManagerFactoryBean "uses the JPA PersistenceProvider autodetection mechanism". Unfortunately, this JPA deployment is too limited in that you cannot wire your own DataSource bean into it.

    It would be helpful if, in a future Spring release, LocalContainerEntityManagerFactoryBean could default to this same "JPA PersistenceProvider autodetection mechanism" to make switching providers as simple as changing (which provider jars are on) your classpath.