Search code examples
mongodbjakarta-eejpamongodb-javajava-ee-7

How to configure Eclipselink nosql JPA implementation with mongodb nosql database?


I want to use JPA to create an entity class that can be used with the persistence context to access my db2 nosql database. The problem is the @NoSql annotation is not being found.

As per http://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Advanced_JPA_Development/NoSQL/Configuring, I:

  1. Created a web project
  2. Enabled JPA via project properties-> Project Facets -> Check mark JPA v2.1
  3. Under Project properties -> JPA -> Set Platform to EclipseLink 2.5x, Set JPA Implementation to Library Provided by Target Runtime
  4. Setup server.xml with the datasource and the persistence.xml

I have java.persistence.org but not java.persistence.org.oracle.nosql. I'm not sure if I am suppose to download it or it should already be setup. And I also do not know how to use maven (and I would prefer not to).

Most tutorials online either only show HOW to use (and not configure) or use mysql connector and somewhere in the project config it just works. I greatly appreciate assistance!


Solution

  • I solved the problem by following this blog post: https://blogs.oracle.com/NoSQL/entry/eclipselink_jpa_and_oracle_nosql.

    Excerpt:

    Now at first glance it looks like EclipseLink 2.5 includes support for NoSQL databases right out of the box, but in fact if you look closely there is another specific NoSQL plugin download necessary. Download, unzip and save this plugin in a directory e.g. /nosql-plugin . Later you’ll need to get some libraries from it.

    So go here to get the jar files and import the following into your project

    1. org.eclipse.persistence.nosql_2.5.0*.jar
    2. org.eclipse.persistence.oracle.nosql_2.5.0*.jar
    3. javax.resource_1.5.0*.jar

    To import go right-click project -> properties -> java build path -> Libraries tab -> Add External Jar -> Navigate to the jar files and import