Red Hat
Oct 30, 2013
by Davide D'Alto

After one month from the previous release we are happy to announce the new Hibernate OGM 4.0.0.Beta4.

Initial embedded Neo4j integration

Hibernate OGM can now work with Neo4j, a fully transactional property graph database.

Graph databases represent the data as a system of interconnected nodes and it works very well when you need to store information like the relationship between people in social networks for example. In addition, in a property graph, you can also add properties to the elements of the graph.

Hibernate OGM maps an entity as a node where the attributes of the entity become properties of the node. At the moment we add some additional properties for the conversion of the node into the entity but we are planning to replace them using the label mechanism added in the latest Neo4j versions.

The relationship between two nodes represents an association between two entities. Currently a bidirectional association requires two relationships but we are going to change this since Neo4j can navigate a relationship in both directions.

The integration with Neo4j is experimental but we are planning on improving it soon. Please, let us know what you think or help us improving it.

Native query support for MongoDB

One missing feature in the previous releases was the ability to retrieve managed entities using the query language of the database of your choice. This is particularly useful if the query language supports specific features unavailable to JP-QL or currently non implemented.

We started to work on this feature and it is now possible to execute a MongoDB query using the org.hibernate.Session or the javax.persistence.EntityManager.

Let's look at an example using the session:

List<OscarWildePoem> result = session.createSQLQuery( "{ $query : { author : 'Oscar Wilde' }, $orderby : { name : 1 } }" )
    .addEntity( OscarWildePoem.TABLE_NAME, OscarWildePoem.class )

and one using the entity manager:

List<OscarWildePoem> results = entityManager.createNativeQuery( "{ $query : { author : 'Oscar Wilde' }, $orderby : { name : 1 } }", OscarWildePoem.class )

How to try it

You can take a look at the documentation or check how you can download Hibernate OGM 4.0.0.Beta4.

Many thanks to all the contributors that made this release possible whether it be via pull requests, bug reports or feedback on the forum.

Original Post