ctudose / java-persistence-spring-data-hibernate

51 stars 43 forks source link

Ch18/hibernate-ogm code does not work #3

Open Mehdi-HAFID opened 1 year ago

Mehdi-HAFID commented 1 year ago

When I try to run the test class HibernateOGMTest I get for mongodb

javax.persistence.PersistenceException: Unable to build entity manager factory

main.HibernateOGMTest.setUp(HibernateOGMTest.java:26)

one of the warning says WARN: HHH015016: Encountered a deprecated javax.persistence.spi.PersistenceProvider [org.hibernate.ejb.HibernatePersistence]; use [org.hibernate.jpa.HibernatePersistenceProvider] instead.

error out here entityManagerFactory = Persistence.createEntityManagerFactory("ch18.hibernate_ogm");

persistence.xml & pom.xml are exact match as the source code so no typo there.

But when I changed to using neo4j instead of mongodb there is no error anymore and the tests pass. can anyone confirm that the issue exists for them too?

mklinkj commented 3 months ago

Hello

According to the Korean translator's explanation, using the latest version of MongoDB, there was an error, and when using version 5.0, there was no error.

I also tried running it in a MongoDB 5.0.26 environment, and confirmed that the test code passes.

root@mongodb_docker_host:/# mongo --version
MongoDB shell version v5.0.26
Build Info: {
    "version": "5.0.26",
    ...

To resolve class access exceptions to modules not registered as unnamed modules, and file encoding warnings (my Windows Terminal Encoding: MS949), I also added the following to the pom.xml

Result: mvn clean test

image

have a nice day. 👍


I think the more specific cause is that the mongo-java-driver version used by hibernate-ogm-mongodb:4.2.0.Final is old.