3

We are looking at using MongoDB as our database in our Java Server-side application. In my earlier project we were using Hibernate to abstract the underlying SQL database, so that we could switch from MySQL to Postgres (for example) without changing application code. (this was a + that Hibernate gave us apart from the usual ORM feature).
I did a search for a similar abstraction layer for Document-oriented NoSQL Databases, and ended up with no results !

Though MongoDB suffices our requirements of today, if a better Document-oriented NoSQL DB comes up 3 years down the line, we dont want to change our application code to move to the new DB.

One solution is for us to write the abstraction layer by ourselves (which we will if we are left with no other option).

But I would be surprised if people coming from ORM world coded directly onto the NoSQL DB interfaces ?! Is database independence not a concern in the NoSQL world ? Or is it achieved by some other means ?

Community
  • 1
  • 1
2020
  • 2,821
  • 2
  • 23
  • 40
  • Related question which might give you some insight: http://stackoverflow.com/questions/2153195/hibernate-with-mongodb – Philipp May 21 '13 at 21:21

2 Answers2

6

The reasons for there not being many mature database-agnostic ORM layers for NoSQL are:

  1. They are a lot less standardized. SQL is an ISO standard. When you stick to that standard, you have to make little modifications when you change the underlying database. Document-oriented databases, however, all have their own query languages.

  2. They all work fundamentally different. All document-oriented databases have their own philosophies, strengths, weaknesses and use-cases. A storage strategy which works well on CouchDB might be completely inappropriate to MongoDB. It is hard to use an ORM mapper which can abstract so far that it can find a common denominator in its API which satisfies all of these quirks.

  3. They are still a rather new technology. The sofware ecosystem around them still needs a few years to evolve to a standard similar to SQL.

But note that while there are no solutions for database-agnostic ORMs in the document-oriented database world, there are plenty of ORM wrappers for specific databases. You didn't mention which programming language you are using, but there are solutions for most mainstream languages. This is definitely preferred over rolling your own.

Philipp
  • 67,764
  • 9
  • 118
  • 153
  • There's Mongolink for java. I've used PHPs Doctrine for MongoDB (and there's CouchDB alpha support!). On the other hand, when you'd compare Doctrine's Mongo ODM to PHP Mongo driver, they are not that differenet to use. – mrówa May 21 '13 at 21:31
0

You can use spring data if your are working with mongo, also you should implement the repository pattern. Even in that way as was mentioned before, it will not be so agnostic as SQL frameworks that allows that, but if you are able to implement this in a good level as mvc pattern, it will be enough for your solution i think.

montusokar
  • 198
  • 8