Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which is the best java driver for mongodb access?

Tags:

java

mongodb

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? Would it be morphia, mungbean or daybreak. Would prefer some practical experiences with users who have gone through this path before.

like image 924
Sam Avatar asked May 19 '10 17:05

Sam


People also ask

Is there a JDBC driver for MongoDB?

The MongoDB Atlas SQL JDBC Driver provides SQL connectivity to MongoDB Atlas for client applications developed in Java. See the Atlas SQL Documentation for more information. MongoDB Atlas SQL JDBC is a JDBC Type 4 driver compatible with the JDBC 4.2 specification.

How do you connect Java to MongoDB?

To connect to MongoDB on your local instance and default port, you can just omit the URI part of the above, or use a URI like 'mongodb://localhost:27017'. For MongoDB Atlas, you can find the connection string in the cluster console – and make sure you've whitelisted your development IP address for access.

What is the MongoDB driver?

The official MongoDB Node. js driver allows Node. js applications to connect to MongoDB and work with data. The driver features an asynchronous API which allows you to interact with MongoDB using Promises or via traditional callbacks.

Is MongoDB compatible with Java?

All features are supported.


1 Answers

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.
like image 158
Sam Corder Avatar answered Sep 21 '22 23:09

Sam Corder