I am trying a simple Mongo DB and Hibernate OGM example. Here is my persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="mongo-ogm" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ogm.jpa.HibernateOgmPersistence</provider>
<class>com.test.Employee</class>
<properties>
<!-- <property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.JBossStandAloneJtaPlatform"/> -->
<property name="hibernate.ogm.datastore.provider" value="mongodb"/>
<property name="hibernate.ogm.datastore.database" value="mongotest"/>
<property name="hibernate.ogm.datastore.create_database" value="true"/>
<property name="hibernate.ogm.datastore.host" value="mymongo"/>
<property name="hibernate.ogm.datastore.port" value="1234"/>
</properties>
</persistence-unit>
</persistence>
In the logs, I see
INFO: OGM001206: Mongo database named [mongotest] is not defined. Creating it!
I expect that the database mongotest
should be created in Mongo DB after the application boots up.. but it does not show up when I execute show dbs
in Mongo. Also, my JPA based create (em.persist
) does not throw any errors - I am not sure what's happening behind the scenes. This is fat JAR based setup (not a Java EE WAR)