Help

We have been quiet for too long on Hibernate OGM. It is time for us to speak up because we have a lot to show. And to celebrate, we are releasing its first beta.

What is Hibernate OGM

Hibernate OGM is for NoSQL datastores what Hibernate ORM is for relational databases. A way to persist your objects into a native datastore. The good thing is that Hibernate OGM aims at supporting all of JPA features (and the Hibernate native APIs):

  • all the mapping annotations, not a selected few
  • the APIs
  • the semantic (cascade etc)
  • and JP-QL

Work on the NoSQL side

We initially started with Infinispan as single backend and we worked our way to abstract it to support more:

Infinispan

We did not stand still on Infinispan. We greatly improved the backend in particular by using the FineGrainedAtomicMap class to store data and benefit from its increased scalability. See more in the performance section later on.

Ehcache

Ehcache was the first to jump on the wagon and propose an alternative backend implementation. Kudos to Alex Snaps and Greg Luck for taking this bet and help us improve our abstraction API.

MongoDB

MongoDB was the first non key-value based NoSQL solution we supported and we worked very hard to make sure the mapping was akin to what a developer would have designed without Hibernate OGM. For example, identifiers are mapped to the _id property and association information is embedded in the entity by default.


    {
        "_id" : "owner0001",
        "name": "Emmanuel",
        "twitter": "emmanuelbernard",
        "bankAccounts" : [
            { "bankAccounts_id" : "accountXYZ" }
        ]
    }



You can override that setting with various other mapping strategies.

We have more ideas we want to implement to optimize the Hibernate OGM - MongoDB integration and we will be working with folks like Jeff Yemin from 10gen to make sure we do the most natural mapping for MongoDB and that our access layer is as efficient as possible.

Note that we have decided to enable the MongoDB safe mode by default in Hibernate OGM as we thought it made more sense for models persisted with Hibernate OGM and because we don't want to be responsible for killing kittens. You can switch this back off of course.

Other NoSQL engines

Expect the list of supported NoSQL engines to grow as we continuously strive to integrate more and more engines to cover the full bandwidth of NoSQL solutions. Come and talk to us if you want to help out! You can either contribute to any ongoing effort or even start a new one. It's not that hard.

Performance considerations

We worked a lot around performance. The project started as an experiment but we did not manage to make it fail ;) So this time around we worked on performance optimizations.

By side effect, we also improved performance of Hibernate ORM - we reuse the same core engine. We also entered a chase with the Infinispan team to see which of Hibernate OGM or Infinispan was consuming the most time in the call stack. We went back and forth a few times and both projects reduced their overhead by a lot!

At the moment, the profiler does not show much overhead on using Hibernate OGM's stack compared to directly using the underling NoSQL datastore.

Query support

While you won't unfortunately see much in this release, we have been hard at work on the JP-QL query support. Sanne wrote a JP-QL query parser that will be flexible enough for our needs. In fact this is also likely going to be the foundation for the next-gen parser of Hibernate ORM.

He has also worked on the first steps to convert a JP-QL query into an Hibernate Search query. This will let you use Hibernate Search as an internal index and query system besides your NoSQL store. This can either replace or complement the query capability of the NoSQL solution.

Today, this solution can answer simple queries already (make sure to use the Hibernate Session API).

We also have been working on integrating Teiid's query engine which will be our way towards complex queries not natively supported by the underlying NoSQL engine. The plan is to combine the JP-QL parser, the Teiid query engine and write native support for the various NoSQL query options.

We have a great plan but that would take a lot of words to explain so let me save that for a future post.

In the mean time, you can use Hibernate OGM and do queries in two ways:

  1. use Hibernate Search to index your entities and write Hibernate Search queries directly. What is nice about this model is that it's a natural extension to the Hibernate or JPA APIs (managed entities are returned etc)
  2. use the native query capability of your underlying NoSQL store. Because Hibernate OGM tries to map data in a natural way, it's easy to simply query the NoSQL store directly

We hope to show you JP-QL support very soon as the foundations are now built. If you are interested in how we plan on doing queries, come talk to us or go read the architecture chapter in our reference documentation

Community, documentation and download

We worked on many more stuff like better JPA support, better ease of use, less redundant data structures, etc but this post is too long already. Check out the changelog if you are interested.

This project would be nowhere without the help from our community and contributors. Special thanks to:

  • Guillaume Scheibel who literally made MongoDB's support happen
  • Alan Fitton and Oliver Carr for their work on MongoDB associations support
  • Nicolas Helleringer - he is always around somewhere
  • Khanh Maudoux for his experimentation around Cassandra
  • Davide D'Alto for his experimentation on Neo4J and a few other things
  • Seiya Kawashima for his experimentation around Redis and Voldemort

If you are interested in contributing, come talk to us, we have many plans and a humongous todo list.

And guys we took great pain - literally - to write a very good reference guide, so go read it and go download Hibernate OGM.

Enjoy

6 comments:
 
03. Oct 2012, 15:48 CET | Link
Nicolas Helleringer

Congratulations !!

ReplyQuote
 
03. Oct 2012, 16:11 CET | Link
Guillaume Scheibel

Congrats ! This is finally happening, let's make it fly :)

 
03. Oct 2012, 16:54 CET | Link
Scott Marlow

Congratulations!

 
05. Oct 2012, 14:53 CET | Link
Nikita

Please don't forget about Cassandra db support too!

 
05. Oct 2012, 20:03 CET | Link
Nikita wrote on Oct 05, 2012 08:53:
Please don't forget about Cassandra db support too!

Of course! Some work was done already: https://github.com/hibernate/hibernate-ogm/pull/100

 
17. Sep 2013, 09:21 CET | Link
Sravan

Can u please share working example of Spring,Hibernate and Infinispan as Hibernate 2nd level cache..

my mail id: sravankumar4rmhyd@gmail.com

Thanks, Sravan Kumar

Post Comment