开发者

Which is the best java driver for mongodb access?

I have no experience with MongoDB and we are trying to port a JPA application to be based on MongoDB. There are 3 drivers mentioned for porting java here. Which driver would be the easiest to use for converting my existing JPA application?开发者_如何学C Would it be morphia, mungbean or daybreak. Would prefer some practical experiences with users who have gone through this path before.


Morphia isn't a driver but a wrapper around the official java driver. It has a pretty active community.

Mungbean is an alternative community supported driver and POJO mapper. Having written a community supported driver myself, I wouldn't say that, that is necessarily a bad thing but it is like any open source project. You have to look at the vitality of the project.

Daybreak claims to be very new and experimental. Unless you have the stomach for it, I wouldn't touch it (yet).

The existing plain java driver is basic but has all the functionality. 10gen is working on a redo of it to address some of the warts of the old one. You may also want to look into that.

Some things you need to consider when using a mapper:

  • How easy is it to setup?
  • Can I override names?
  • Can some fields be marked as not persisted?
  • What happens to the data if it is in the document but not mapped in the static object? Does it get lost on a save?
  • (Advanced) Can I plug into the configuration engine to do custom serialization? You may want to do that if you have existing POJOs that already have attributes for another persistence engine or serializer.


For those searching this question in the future, look up Hibernate OGM. That's not a typo. OGM is the Hibernate project's NoSQL Object Mapper. It requires a bit of tweaking, but is an extremely easy path forward to move from relational to non-relational.

Just recently I migrated an application developed on JPA and it was mostly just a matter of modifying persistence.xml to get it to work on MongoDB. MongoDB is even on their list of officially supported data stores.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜