Setting up the application serverYou probably know that Glassfish is shipped with Eclipse Link for the JPA2.0 implementation, so the first part is to make Hibernate ORM 4 available. The easiest way is to copy into the %GLASSFISH_HOME%/glassfish/domains/domain1/lib/ folder the required JARs to run Hibernate ORM.
Those JARs are:
Because OGM is depending on ORM, to avoid any version conflicts I choose to use (as far as possible) the same version of Hibernate JARs that OGM has been built with: 4.2.0 (just hibernate-commons-annotations is in 4.0.2). And that's all, Glassfish is ready.
To use Hibernate ORM, you just have to specify the provider is:
<provider>org.hibernate.ejb.HibernatePersistence</provider>For the OGM part, we just have to copy OGM JARs into the lib folder (mentioned above), those JARs are:
For more information about the libraries version, I suggest you to refer to the OGM pom file. If you want to use Infinispan rather than EhCache or MongoDB, just copy both hibernate-ogm-infinispan and infinispan-core .
To switch the application on "OGM mode", it's always the same steps:
- use the HibernateOgmPersistence provider
- declare the data store provider you want to work with (hibernate.ogm.datastore.provider)
- if needed, configure the right properties (host, port, etc. )
At this point, you can run the demo and if it works you'll find in the logs: