Hibernate OGM with Hibernate ORM

Hi, did anyone tried Hibernate OGM with Hibernate ORM in a single application?

You need separate persistence units and configuration files to have both ORM and OGM.

I have created different configuration for them, but transaction object is not getting created for OGM. I am getting

threw exception [Handler dispatch failed; nested exception is java.lang.AbstractMethodError: org.neo4j.ogm.drivers.bolt.driver.BoltDriver.newTransaction(Lorg/neo4j/ogm/transaction/Transaction$Type;Ljava/lang/String;)Lorg/neo4j/ogm/transaction/Transaction;] with root cause

You need to attach the Stacktrace so that we can see the root cause.

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘org.springframework.data.neo4j.transaction.SharedSessionCreator#0’: Unsatisfied dependency expressed through method ‘createSharedSession’ parameter 0: Could not convert argument value of type [org.hibernate.internal.SessionFactoryImpl] to required type [org.neo4j.ogm.session.SessionFactory]: Failed to convert value of type ‘org.hibernate.internal.SessionFactoryImpl’ to required type ‘org.neo4j.ogm.session.SessionFactory’; nested exception is java.lang.IllegalStateException: Cannot convert value of type ‘org.hibernate.internal.SessionFactoryImpl’ to required type ‘org.neo4j.ogm.session.SessionFactory’: no matching editors or conversion strategy found
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:723)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:467)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:659)
… 51 more

Now, I am able to create transaction for OGM and ORM, but while using I am getting following error:

org.hibernate.HibernateException: Could not obtain transaction-synchronized Session for current thread

before this I was getting following exception:

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘org.springframework.data.neo4j.transaction.SharedSessionCreator#0’: Unsatisfied dependency expressed through method ‘createSharedSession’ parameter 0: Could not convert argument value of type [org.hibernate.internal.SessionFactoryImpl] to required type [org.neo4j.ogm.session.SessionFactory]: Failed to convert value of type ‘org.hibernate.internal.SessionFactoryImpl’ to required type ‘org.neo4j.ogm.session.SessionFactory’; nested exception is java.lang.IllegalStateException: Cannot convert value of type ‘org.hibernate.internal.SessionFactoryImpl’ to required type ‘org.neo4j.ogm.session.SessionFactory’: no matching editors or conversion strategy found

Maybe it’s because Spring does not integrate OGM. It only integrates the ORM.

Probably you need to add an Aspect so that the @Transactional annotation works with OGM too.

However, it’s impossible to tell what you do because you only provide some exceptions without giving more context.

For more details, check out the How to create a Minimal, Complete, and Verifiable example page from StackOverflow.

He wasn’t actually using Hibernate OGM but Neo4j OGM. More details about this question are on StackOverflow: