Do you need JPA when using MongoDB?

23,039

Solution 1

I think play has support for JPA, but doesn't require JPA. You can just forget about JPA altogether and use whatever API to MongoDB you like (its native API, Brendan's suggestion of Morphia, etc).

Solution 2

As MongoDB is not a relational database, it does not have support for JPA.

There is however Morphia, an Object Document Mapper for MongoDB + Java which closely emulates the JPA model but using MongoDB appropriate semantics. It is known to work well with Play and if you want this kind of Object mapping would be an excellent analog.

Solution 3

DataNucleus already supports MongoDB, for JPA and JDO, the standardised APIs in Java. With that you have portability, unlike with the other APIs

Solution 4

EclipseLink is planning support for MongoDB from JPA.

See, http://wiki.eclipse.org/EclipseLink/DesignDocs/362899

Solution 5

Hibernate OGM provides JPA for MongoDB. MongoDB University has a course for Java Developers, maybe it will help you understand what you want to do.

Share:
23,039

Related videos on Youtube

Admin
Author by

Admin

Updated on November 17, 2020

Comments

  • Admin
    Admin over 3 years

    I'm quite confused between those two. I'm looking at the Play! java framework and it says it uses JPA. I'm thinking about using Play! and MongoDB for the first time in a project. I've used JPA before, but I was using it back then to write to a relational database(mysql).

    MongoDB is not a relational database, so if I want to use it with Play!, will I still be needing JPA? Or just the MongoDB driver?

    I think I'm confusing quite a few things here, so if someone could help clarify things, I'd appreciate it!

  • mandubian
    mandubian almost 13 years
    exactly! JPA is delivered with Play because it's a full web stack so it embeds JPA+Hibernate but you can use something else than JPA. For example for MongoDB, there is Morphia, for SQL/GAE there is Siena and for GAE, there is Objectify.
  • Admin
    Admin almost 13 years
    So Morphia is basically an alternative for the Java MongoDB driver?
  • Brendan W. McAdams
    Brendan W. McAdams almost 13 years
    No, Morphia adds functionality to the Java driver.
  • Brendan W. McAdams
    Brendan W. McAdams almost 13 years
    Do you actually allow the developer to take advantage of MongoDB features such as atomic data modifications, write concerns and embedded objects? Or is it just a generic bucket to keep data?
  • DataNucleus
    DataNucleus almost 13 years
    embedded objects, collections, maps already supported. slaveOk supported. write concerns not yet supported but easy enough to add. similarly mapReduce ought to be simple enough to add. No idea what a "generic bucket" is in the context of JDO/JPA. define atomic operations; DataNucleus only ever updates anything when it is changed, or the user marks it as "dirty". At the end of the day, the user has model classes and performs Java operations on them; these map to JDO/JPA API behaviour. JDOQL/JPQL performed partially in-datastore (where available syntax), the rest can be done in-memory
  • DataNucleus
    DataNucleus almost 13 years
  • Dmitri
    Dmitri about 11 years
    Just want to update this. EclipseLink already comes with MongoDB support for JPA