Hibernate.orgCommunity Documentation
Currently Hibernate OGM supports the following NoSQL datastores:
CouchDB: stores data into CouchDB (document store)
More are planned, if you are interested, come talk to us (see Chapter 1, How to get help and contribute on Hibernate OGM).
For each datastore, Hibernate OGM has specific integration code called a datastore provider. All are in a dedicated maven module, you simply need to depend on the one you use.
Hibernate OGM interacts with NoSQL datastores via two contracts:
DatastoreProvider
which is responsible for
starting and stopping the connection(s) with the datastore
and prop up the datastore if neededGridDialect
which is responsible for
converting an Hibernate OGM operation into a datastore specific operationOnly a few steps are necessary:
Adding the relevant Hibernate OGM module in your classpath looks like this in Maven:
<dependency>
<groupId>org.hibernate.ogm</groupId>
<artifactId>hibernate-ogm-infinispan</artifactId>
<version>4.1.3.Final</version>
</dependency>
The module names are
hibernate-ogm-infinispan
, hibernate-ogm-ehcache
, hibernate-ogm-mongodb
, hibernate-ogm-neo4j
and hibernate-ogm-couchdb
.
The map datastore is included in the Hibernate OGM engine module.
Next, configure which datastore provider you want to use.
This is done via the hibernate.ogm.datastore.provider
option.
Possible values are:
map
(only to be used for unit tests),
infinispan
, ehcache
, mongodb
, neo4j_embedded
or couchdb_experimental
DatastoreProvider
implementationWhen bootstrapping a session factory or entity manager factory programmatically,
you should use the constants declared on OgmProperties
to specify configuration properties
such as hibernate.ogm.datastore.provider
.
In this case you also can specify the provider in form of a class object of a datastore provider type or pass an instance of a datastore provider type:
Map<String, Object> properties = new HashMap<String, Object>();
// pass the type
properties.put( OgmProperties.DATASTORE_PROVIDER, MongoDBDatastoreProvider.class );
EntityManagerFactory emf = Persistence.createEntityManagerFactory( "my-pu", properties );
By default, a datastore provider chooses the best grid dialect transparently
but you can manually override that setting
with the hibernate.ogm.datastore.grid_dialect
option.
Use the fully qualified class name of the GridDialect
implementation.
Most users should ignore this setting entirely and live a happier life instead.
Let’s now look at the specifics of each datastore provider. How to configure it further, what mapping structure is used and more.