# Does Hibernate OGM work with Envers?

**URL:** <https://discourse.hibernate.org/t/does-hibernate-ogm-work-with-envers/4314>\
**Category:** Hibernate OGM\
**Created:** [June 23, 2020, 8:32am UTC](https://discourse.hibernate.org/t/does-hibernate-ogm-work-with-envers/4314 "2020-06-23T08:32:32Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![kira\_cesonia](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/kira_cesonia/32/1114_2.png) [@kira\_cesonia](https://discourse.hibernate.org/u/kira_cesonia)\
**Post date:** [June 23, 2020, 8:32am UTC](https://discourse.hibernate.org/t/does-hibernate-ogm-work-with-envers/4314/1 "2020-06-23T08:32:32Z")

</div>

I am looking for a way to version large documents in MongoDB in an efficient way. Since that sounds like something that a framework should exist for. While researching, I came across Envers and Hibernate OGM.

I am currently in the process of setting up a sample project reflecting our data structure in a simplified way to test this. However, since I am running into some trouble with there, I have not yet been able to get to the point where I can simply test if Hibernate OGM works with Envers.

I have also not found a clear answer on this anywhere. The best I found is this old issue ([https://hibernate.atlassian.net/browse/OGM-98?page=com.atlassian.jira.plugin.system.issuetabpanels:changehistory-tabpanel](https://hibernate.atlassian.net/browse/OGM-98?page=com.atlassian.jira.plugin.system.issuetabpanels:changehistory-tabpanel)) which seems to imply that it does not work. However, since that issue is already kinda old, I figured something might have changed since then.

So, what is the current status? Does Hibernate OGM work with Envers? Because if it doesn’t and I have to write my own versioning solution, then I can just save myself all the trouble of figuring out how to get our Data Model to work in Hibernate OGM.

Thanks in advance,  
Kira  
=^,^=

---

<div class="post-metadata">

**Author:** ![DavideD](https://avatars.discourse-cdn.com/v4/letter/d/48db29/32.png) [@DavideD](https://discourse.hibernate.org/u/DavideD)\
**Post date:** [June 23, 2020, 11:13am UTC](https://discourse.hibernate.org/t/does-hibernate-ogm-work-with-envers/4314/2 "2020-06-23T11:13:53Z")

</div>

We didn’t have time to check so I don’t have an answer. I suppose it’s easy to create a simple project and see if they work together.

My educated guess is that envers uses queries that are not supported by OGM. BUt I don’t know for sure because I’m not familiar with Envers.

---

<div class="post-metadata">

**Author:** ![kira\_cesonia](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/kira_cesonia/32/1114_2.png) [@kira\_cesonia](https://discourse.hibernate.org/u/kira_cesonia)\
**Post date:** [June 24, 2020, 7:28am UTC](https://discourse.hibernate.org/t/does-hibernate-ogm-work-with-envers/4314/3 "2020-06-24T07:28:13Z")

</div>

Honestly, it doesn’t look promising. I’ve tried adding both Hibernate OGM and Envers as dependencies to my project like this:

```auto
plugins {
	id 'java-library'
}

repositories {

    jcenter()
}

dependencies {
    // Use JUnit test framework
    testCompile("org.junit.jupiter:junit-jupiter:5.6.0")
    testCompile("org.junit.platform:junit-platform-runner:1.6.0")
	
	//MongoDB Driver
	compile 'org.mongodb:mongodb-driver:3.6.0'
	compile 'commons-logging:commons-logging:1.2'
	
	//Logging
	compile 'log4j:log4j:1.2.17'
	compile 'org.slf4j:slf4j-log4j12:1.7.25'
	compile 'commons-logging:commons-logging:1.2'
	
	//Versioning
	compile group: 'org.hibernate.ogm', name: 'hibernate-ogm-mongodb', version: '5.4.0.Final'
	compile group: 'org.hibernate', name: 'hibernate-envers', version: '5.4.0.Final'
	compile group: 'org.jboss.narayana.jta', name: 'narayana-jta', version: '5.9.2.Final'
	compile group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.0'
}

```

…and as soon as I do, everything breaks with the following error message, _without me even adding any Envers features_:

```auto
java.lang.NoSuchMethodError: org.hibernate.internal.SessionFactoryImpl.<init>(Lorg/hibernate/boot/spi/BootstrapContext;Lorg/hibernate/boot/spi/MetadataImplementor;Lorg/hibernate/boot/spi/SessionFactoryOptions;)V
	at org.hibernate.ogm.boot.impl.OgmSessionFactoryBuilderImpl.build(OgmSessionFactoryBuilderImpl.java:56)
	at org.hibernate.ogm.boot.impl.OgmSessionFactoryBuilderImpl.build(OgmSessionFactoryBuilderImpl.java:23)
	at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:938)
	at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:56)
	at org.hibernate.ogm.jpa.HibernateOgmPersistence.createEntityManagerFactory(HibernateOgmPersistence.java:57)
	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79)
	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
	at hibernate.OgmAccessorSimpleTest.initialize(OgmAccessorSimpleTest.java:22)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:686)
	at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
	at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149)
	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptLifecycleMethod(TimeoutExtension.java:126)
	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptBeforeAllMethod(TimeoutExtension.java:68)
	at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)
	at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeBeforeAllMethods$8(ClassBasedTestDescriptor.java:375)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeBeforeAllMethods(ClassBasedTestDescriptor.java:373)
	at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.before(ClassBasedTestDescriptor.java:193)
	at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.before(ClassBasedTestDescriptor.java:78)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:132)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:248)
	at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$5(DefaultLauncher.java:211)
	at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:226)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:199)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:141)
	at org.eclipse.jdt.internal.junit5.runner.JUnit5TestReference.run(JUnit5TestReference.java:89)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:542)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:770)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:464)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)

```

For reference, a test project can be found on [https://github.com/Kira-Cesonia/MongoDBVersioningTest](https://github.com/Kira-Cesonia/MongoDBVersioningTest), branch CKNG-82-versioning-expedition-hibernate

---

<div class="post-metadata">

**Author:** ![DavideD](https://avatars.discourse-cdn.com/v4/letter/d/48db29/32.png) [@DavideD](https://discourse.hibernate.org/u/DavideD)\
**Post date:** [June 24, 2020, 7:55am UTC](https://discourse.hibernate.org/t/does-hibernate-ogm-work-with-envers/4314/4 "2020-06-24T07:55:05Z")

</div>

That’s because OGM 5.4 requires ORM 5.3 and I think you need to use the same version for Envers (5.3)

---

<div class="post-metadata">

**Author:** ![kira\_cesonia](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/kira_cesonia/32/1114_2.png) [@kira\_cesonia](https://discourse.hibernate.org/u/kira_cesonia)\
**Post date:** [June 24, 2020, 8:53am UTC](https://discourse.hibernate.org/t/does-hibernate-ogm-work-with-envers/4314/5 "2020-06-24T08:53:32Z")

</div>

Ah, thanks for pointing that out. Just out of curiosity, was there any realistic way for me to have known that? =^,~’=

Anyway, I now adjusted my build.gradle to look like this:

```auto
plugins {
	id 'java-library'
}

repositories {

    jcenter()
}

dependencies {
    // Use JUnit test framework
    testCompile("org.junit.jupiter:junit-jupiter:5.6.0")
    testCompile("org.junit.platform:junit-platform-runner:1.6.0")
	
	//MongoDB Driver
	compile 'org.mongodb:mongodb-driver:3.6.0'
	compile 'commons-logging:commons-logging:1.2'
	
	//Logging
	compile 'log4j:log4j:1.2.17'
	compile 'org.slf4j:slf4j-log4j12:1.7.25'
	compile 'commons-logging:commons-logging:1.2'
	
	//Versioning
	compile group: 'org.hibernate.ogm', name: 'hibernate-ogm-mongodb', version: '5.4.0.Final'
	compile group: 'org.hibernate', name: 'hibernate-envers', version: '5.3.0.Final'
	compile group: 'org.jboss.narayana.jta', name: 'narayana-jta', version: '5.9.2.Final'
	compile group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.0'
}

```

…and that caused my old tests to run and pass again. However, as soon as I added the @Audited annotation to one of my entities, I got this error message before any of my old tests are even being run:

```auto
java.lang.NoClassDefFoundError: org/hibernate/internal/util/compare/EqualsHelper
	at org.hibernate.envers.internal.entities.PropertyData.equals(PropertyData.java:172)
	at java.base/java.util.HashMap.getNode(HashMap.java:567)
	at java.base/java.util.LinkedHashMap.get(LinkedHashMap.java:440)
	at org.hibernate.envers.internal.entities.mapper.MultiPropertyMapper.addComponent(MultiPropertyMapper.java:51)
	at org.hibernate.envers.configuration.internal.metadata.ComponentMetadataGenerator.addComponent(ComponentMetadataGenerator.java:56)
	at org.hibernate.envers.configuration.internal.metadata.AuditMetadataGenerator.addValueInSecondPass(AuditMetadataGenerator.java:271)
	at org.hibernate.envers.configuration.internal.metadata.AuditMetadataGenerator.addValue(AuditMetadataGenerator.java:356)
	at org.hibernate.envers.configuration.internal.metadata.AuditMetadataGenerator.addProperties(AuditMetadataGenerator.java:384)
	at org.hibernate.envers.configuration.internal.metadata.AuditMetadataGenerator.generateSecondPass(AuditMetadataGenerator.java:752)
	at org.hibernate.envers.configuration.internal.EntitiesConfigurator.configure(EntitiesConfigurator.java:109)
	at org.hibernate.envers.boot.internal.EnversServiceImpl.doInitialize(EnversServiceImpl.java:154)
	at org.hibernate.envers.boot.internal.EnversServiceImpl.initialize(EnversServiceImpl.java:118)
	at org.hibernate.envers.boot.internal.AdditionalJaxbMappingProducerImpl.produceAdditionalMappings(AdditionalJaxbMappingProducerImpl.java:101)
	at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:297)
	at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:904)
	at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:935)
	at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:56)
	at org.hibernate.ogm.jpa.HibernateOgmPersistence.createEntityManagerFactory(HibernateOgmPersistence.java:57)
	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79)
	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
	at hibernate.OgmAccessorSimpleTest.initialize(OgmAccessorSimpleTest.java:22)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:686)
	at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
	at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149)
	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptLifecycleMethod(TimeoutExtension.java:126)
	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptBeforeAllMethod(TimeoutExtension.java:68)
	at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)
	at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeBeforeAllMethods$8(ClassBasedTestDescriptor.java:375)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeBeforeAllMethods(ClassBasedTestDescriptor.java:373)
	at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.before(ClassBasedTestDescriptor.java:193)
	at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.before(ClassBasedTestDescriptor.java:78)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:132)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:248)
	at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$5(DefaultLauncher.java:211)
	at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:226)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:199)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:141)
	at org.eclipse.jdt.internal.junit5.runner.JUnit5TestReference.run(JUnit5TestReference.java:89)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:542)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:770)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:464)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)
Caused by: java.lang.ClassNotFoundException: org.hibernate.internal.util.compare.EqualsHelper
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
	... 76 more

```

Is this already an indicator that Hibernate OGM and Envers are incompatible? Or is it a dependency issue that is still fixable? For me, it’s really hard to tell. At the very least, I can’t seem to find an EqualsHelper class in the Javadocs of Hibernate OGM ([https://javadoc.io/doc/org.hibernate.ogm/hibernate-ogm-core/latest/index.html](https://javadoc.io/doc/org.hibernate.ogm/hibernate-ogm-core/latest/index.html)). Is this an indicator that the two are incompatible? Or am I looking in the wrong place?

---

<div class="post-metadata">

**Author:** ![DavideD](https://avatars.discourse-cdn.com/v4/letter/d/48db29/32.png) [@DavideD](https://discourse.hibernate.org/u/DavideD)\
**Post date:** [June 24, 2020, 12:25pm UTC](https://discourse.hibernate.org/t/does-hibernate-ogm-work-with-envers/4314/6 "2020-06-24T12:25:40Z")

</div>

> Ah, thanks for pointing that out. Just out of curiosity, was there any realistic way for me to have known that? =^,~’=

There is a compatibility table on the website: [5.4 series - Hibernate OGM](http://hibernate.org/ogm/releases/5.4/)  
The second approach is to check the transitive dependencies in the pom: [https://mvnrepository.com/artifact/org.hibernate.ogm/hibernate-ogm-core/5.4.1.Final](https://mvnrepository.com/artifact/org.hibernate.ogm/hibernate-ogm-core/5.4.1.Final)

---

<div class="post-metadata">

**Author:** ![DavideD](https://avatars.discourse-cdn.com/v4/letter/d/48db29/32.png) [@DavideD](https://discourse.hibernate.org/u/DavideD)\
**Post date:** [June 24, 2020, 12:33pm UTC](https://discourse.hibernate.org/t/does-hibernate-ogm-work-with-envers/4314/7 "2020-06-24T12:33:34Z")

</div>

> [@kira\_cesonia](#):
>
> ```auto
> java.lang.NoClassDefFoundError: org/hibernate/internal/util/compare/EqualsHelper
> 
> ```

This class exists in ORM 5.3 but not in 5.4, so I think you are still using the wrong version somewhere in the project.

---

<div class="post-metadata">

**Author:** ![kira\_cesonia](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/kira_cesonia/32/1114_2.png) [@kira\_cesonia](https://discourse.hibernate.org/u/kira_cesonia)\
**Post date:** [June 25, 2020, 5:05am UTC](https://discourse.hibernate.org/t/does-hibernate-ogm-work-with-envers/4314/8 "2020-06-25T05:05:33Z")

</div>

Well, could it be because I’m using `org.hibernate.ogm', name: 'hibernate-ogm-mongodb', version: '5.4.0.Final`? That’s really the only reference to a 5.4 I can find. And as you said before, "OGM 5.4 requires ORM 5.3 ". And that version step also seems to exist upstream, so if I switch to OGM 5.3 I’ll need ORM 5.2, and we’ll have that discrepancy again. I don’t think it’s possible to get them on the same level.

Anyway, this is my complete dependencies. I don’t use any other dependencies in the entire project. If a wrong version of something is loaded, it happens here, and in a way that I can’t reconstruct. Is there a way to create, like, a dependency graph, or something?

```auto
plugins {
	id 'java-library'
}

repositories {

    jcenter()
}

dependencies {
    // Use JUnit test framework
    testCompile("org.junit.jupiter:junit-jupiter:5.6.0")
    testCompile("org.junit.platform:junit-platform-runner:1.6.0")
	
	//MongoDB Driver
	compile 'org.mongodb:mongodb-driver:3.6.0'
	compile 'commons-logging:commons-logging:1.2'
	
	//Logging
	compile 'log4j:log4j:1.2.17'
	compile 'org.slf4j:slf4j-log4j12:1.7.25'
	compile 'commons-logging:commons-logging:1.2'
	
	//Versioning
	compile group: 'org.hibernate.ogm', name: 'hibernate-ogm-mongodb', version: '5.4.0.Final'
	compile group: 'org.hibernate', name: 'hibernate-envers', version: '5.3.0.Final'
	compile group: 'org.jboss.narayana.jta', name: 'narayana-jta', version: '5.9.2.Final'
	compile group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.0'
}

```

The blackest box here would be naranya, and checking it on the maven repository, it does not _seem_ to have a dependency on ORM 5.4 (but I can’t be sure).

Anyway, bottom line seems to be that Hibernate OGM does not support Envers.

---

<div class="post-metadata">

**Author:** ![DavideD](https://avatars.discourse-cdn.com/v4/letter/d/48db29/32.png) [@DavideD](https://discourse.hibernate.org/u/DavideD)\
**Post date:** [June 25, 2020, 8:16am UTC](https://discourse.hibernate.org/t/does-hibernate-ogm-work-with-envers/4314/9 "2020-06-25T08:16:01Z")

</div>

The right dependencies to use are (updated to the latest available):  
OGM: 5.4.1.Final  
Envers: 5.3.6.Final  
MondoDriver: 3.9.1

This way they are aligned.

This is the gradle build I’ve used:

```auto
plugins {
	id 'java-library'
}

repositories {
    jcenter()
}

dependencies {
    // Use JUnit test framework
    testCompile("org.junit.jupiter:junit-jupiter:5.6.0")
    testCompile("org.junit.platform:junit-platform-runner:1.6.0")
	
	//MongoDB Driver
	compile 'org.mongodb:mongodb-driver:3.9.1'

	//Logging
	compile 'log4j:log4j:1.2.17'
	compile 'org.slf4j:slf4j-log4j12:1.7.25'
	compile 'commons-logging:commons-logging:1.2'
	
	//Versioning
	compile group: 'org.hibernate.ogm', name: 'hibernate-ogm-mongodb', version: '5.4.1.Final'
	compile group: 'org.hibernate', name: 'hibernate-envers', version: '5.3.6.Final'
	compile group: 'org.jboss.narayana.jta', name: 'narayana-jta', version: '5.9.2.Final'
	compile group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.0'
}

def loggingSummary(result, desc) {
	if ( !desc.parent ) { // will match the outermost suite
		def output = "Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} passed, ${result.failedTestCount} failed, ${result.skippedTestCount} skipped)"
		def repeatLength = output.length() + 1
		println '\n' + ('-' * repeatLength) + '\n' + output + '\n' + ('-' * repeatLength)
	}
}

test {
        // Enable Jupiter
	useJUnitPlatform()

	afterSuite { desc, result ->
		loggingSummary( result, desc )
	}
}

```

This will make the ClassNotFound or NotSuchMethod exceptions disappear.  
Note that the tests weren’t successful when I built it but it seemed a configuration problem and I didn’t have the time to investigate it (probably something missing in my MongoDB ). I will leave that to you if you want to have a look.

---

<div class="post-metadata">

**Author:** ![DavideD](https://avatars.discourse-cdn.com/v4/letter/d/48db29/32.png) [@DavideD](https://discourse.hibernate.org/u/DavideD)\
**Post date:** [June 25, 2020, 2:49pm UTC](https://discourse.hibernate.org/t/does-hibernate-ogm-work-with-envers/4314/10 "2020-06-25T14:49:46Z")

</div>

While answering [your question on SO](https://stackoverflow.com/questions/62528310/hibernate-ogm-discriminating-polymorphic-objects-abstract-superclasses/62538284#62538284) I’ve figured out why OGM won’t work with envers.

The issue is that the entities used by envers are not mapped or recognized by OGM. So, an initial step would be to register somewhere these types.

I’ve forked your project: [https://github.com/DavideD/MongoDBVersioningTest](https://github.com/DavideD/MongoDBVersioningTest)  
and the error I see now is:

```auto
Caused by: org.hibernate.HibernateException: OGM000059: Unable to find a GridType for org.hibernate.type.CustomType`

```

That’s caused by this Envers type:

```auto
org.hibernate.envers.internal.entities.RevisionTypeType

```

Not sure how hard it might be to registered this entities when the library is on the classpath.

---

<div class="post-metadata">

**Author:** ![DavideD](https://avatars.discourse-cdn.com/v4/letter/d/48db29/32.png) [@DavideD](https://discourse.hibernate.org/u/DavideD)\
**Post date:** [June 25, 2020, 2:52pm UTC](https://discourse.hibernate.org/t/does-hibernate-ogm-work-with-envers/4314/11 "2020-06-25T14:52:38Z")

</div>

Damn, I could have read the comment section of [the issue you have mentioned](https://hibernate.atlassian.net/browse/OGM-98?page=com.atlassian.jira.plugin.system.issuetabpanels%3Achangehistory-tabpanel):

> I just tried with OGM 4.0.0.Beta2 it doesn’t work:
> 
> Caused by: org.hibernate.HibernateException: Unable to find a GridType for org.hibernate.type.CustomType  
> at org.hibernate.ogm.type.impl.TypeTranslatorImpl.getType(TypeTranslatorImpl.java:152)  
> at org.hibernate.ogm.persister.OgmEntityPersister.(OgmEntityPersister.java:224)  
> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
> 
> When I put my debugger on TypeTranslatorImpl.java i see that type.name = “org.hibernate.envers.entities.RevisionTypeType”. I think this is related to OGM-75, since RevisionType is a CustomType.

---

<div class="post-metadata">

**Author:** ![kira\_cesonia](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/kira_cesonia/32/1114_2.png) [@kira\_cesonia](https://discourse.hibernate.org/u/kira_cesonia)\
**Post date:** [June 26, 2020, 4:50am UTC](https://discourse.hibernate.org/t/does-hibernate-ogm-work-with-envers/4314/12 "2020-06-26T04:50:47Z")

</div>

@DavideD : Thanks for investigating. From what I read it’s probably easier to implement my own versioning solution here, especially since I still have massive problems with getting Hibernate to accept my class model (while it already nicely works with MongoDB Driver).
