0

I really like the simplicity of spring data repository, however need to use hibernate as persistence provider for consistency and few other factors. (I am using mongodb but not using mongo template). Few things I noticed --

  1. The HibernateJpaVendorAdapter uses "org.springframework.orm.jpa.vendor.SpringHibernateEjbPersistenceProvider"

  2. The provider configured with the persistence unit ( ""org.hibernate.ogm.jpa.HibernateOgmPersistence" ) is not considered, while constructing the EntityManagerFactory through a "org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" bean.

  3. If there are multiple persistence units configured for the project there is no apparent way to associate a persistence unit for a repository.

Questions:

  1. Is there a way to use the configured persistence provider , instead of the default one ? The default provider is not working with mongodb.

  2. Is there a way to associate a repository with a specific persistence unit ?

Sanne
  • 6,027
  • 19
  • 34
Rajesh
  • 419
  • 1
  • 6
  • 20

1 Answers1

0

A partial solution was to

  1. implement org.springframework.orm.jpa.vendor.AbstractJpaVendorAdapter and return an instance of org.hibernate.ogm.jpa.HibernateOgmPersistence in getPersistenceProvider() method

  2. Source the jpaVendorAdapter property for entityManagerFactory bean in spring config

However it still doesn't work good wherever there is reference to Pageable. Some design change can circumvent the issue.

Phiter
  • 14,570
  • 14
  • 50
  • 84
Rajesh
  • 419
  • 1
  • 6
  • 20