Hello guys,
I come across with a big issue.
I am trying to configure 2 entityManager in my Spring MVC app : 1 for MySQL and 1 for MongoDB.
When I use hibernate-core version : 5.2.8.Final with hibernate-ogm-core : 5.1.0.Final, I have this exception :
Code:
java.lang.NoClassDefFoundError: org/hibernate/resource/transaction/TransactionCoordinatorBuilder
I googled and found that this is due to dependencies compatibility.
I try to downgrade these versions like here :
https://github.com/hibernate/hibernate-ogm/blob/5.0.1.Final/bom/pom.xml#L43but it raised another exception :
Code:
java.lang.NoSuchMethodError: org.hibernate.engine.spi.SessionFactoryImplementor.getProperties()Ljava/util/Map;
Here my entityManager configuration :
Code:
@Configuration
@EnableJpaRepositories( basePackages = "com.app.persistence.mongo.repository", entityManagerFactoryRef = "mongoEntityManager" )
public class MongoDBConfig {
@Bean( name = "mongoEntityManager" )
public LocalContainerEntityManagerFactoryBean mongoEntityManagerFactory() {
// ====HIBERNTATE OGM PROPERTIES=======
Map<String, Object> properties = new HashMap<>();
properties.put( OgmProperties.DATASTORE_PROVIDER,
MongoDBDatastoreProvider.class );
properties.put( OgmProperties.HOST, "localhost:27017" );
properties.put( OgmProperties.DATABASE, "starter" );
properties.put( OgmProperties.CREATE_DATABASE, "true" );
LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
entityManagerFactoryBean.setPackagesToScan(
"com.app.persistence.mongo.entities" );
entityManagerFactoryBean.setPersistenceProviderClass( HibernateOgmPersistence.class );
entityManagerFactoryBean.setJpaPropertyMap( properties );
return entityManagerFactoryBean;
}
@Bean
public JpaTransactionManager transactionManager() {
return new JpaTransactionManager( mongoEntityManagerFactory().getObject() );
}
}
When I disable this entityManager configuration and using hibernate-core 5.2.8.Final it works fine but I can only persist data in MySql database.
Could someone guide me?
Thanks a lot.