views:

1047

answers:

2

I'm looking for resources showing how to integrate MongoDB with Hibernate (preferably from within spring) so that I can switch between a RDBMS and a NoSql alternative: does anyone have experience doing this?

+6  A: 

You can't easily do this. The point of Hibernate is to map Java Objects to a relational database. Although Hibernate abstracts a lot of details away you still need to understand how relational databases work with things such as foreign and primary keys, and the performance implications of queries you run. MongoDB requires an entire different way of designing your database focusing on objects instead of columns and tables. while you may be able to create a Hibernate dialect for MongoDB creating a design that would work on both a relational database and a NoSql database will give you a design that works poorly on both.

Jared
A: 

Well just to give you an example, I am doing somehting simmilar. In ColdFusion, Hibernate is integrated and in order to save your Hibernate Object, you hvae to do EntitySave(Obj). However what we have done is build the Orm object, and then use a mongoDB Coldfusion component and just save the object by going mongo.Save(obj,collectionName).

Faisal Abid