MongoDB to Java integration

2019-02-09 06:41发布

问题:

We am trying to convert our old Oracle sql application into NO-SQL and we have chosen Mongo DB.

Are there any ORM support for Mongo DB like Hibernate that reduces our coding?

Can we use JPA specification to build an application for Mongo DB ?

If JPA, which ORM Vendor is best to choose and why ?

Have they come up with no-sql dialect for Mongo DB so that we can build an application using a non relational DB ?

回答1:

DataNucleus JPA provides full persistence to MongoDB using real JPA (as opposed to Spring-Data, Morphia etc which have their own APIs, hence you don't have direct portability - but that may not be your prime concern); in the case of DataNucleus it provides JPA2 (with some preview JPA2.1 features). It also provides JPA persistence to HBase, RDBMS, NeoDatis, Excel, ODF, XML, JSON, LDAP and some others in case you ever need portability to those.



回答2:

Hibernate 4.0 has OGM which supports MongoDB you can see an example of Hibernate with MongoDB here Porting Seam Hotel Booking Example to OGM



回答3:

You can choose Morphia. It is the most stable one over other ORM tools for Mongodb.

Some of the other tools are :

  • Mungbean
  • Spring Data
  • Kundera
  • Jongo

You can find the full list in the MongoDB Third Party Frameworks and Libs part.



回答4:

Try Kundera. Much better performance than Morphia and offers a lot of easy way to code/implement.

-Vivek



回答5:

You should also have a look at EclipseLink's MongoDB support which was released in version 2.4.



回答6:

You may have a look at Spring Data and check out this Tutorial



回答7:

PlayORM also supports MongoDB now. PlayORM is an object NoSQL mapping solution so you can write POJO’s and let it deal with all the details of marshalling/unmarshalling to MongoDB. Visit its documentation here