Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "EclipseLink/UserGuide/JPA/Advanced JPA Development/NoSQL/Persistence Units"

(NoSQL Platforms)
m
 
(8 intermediate revisions by one other user not shown)
Line 1: Line 1:
 +
----
 +
 +
[[Image:Elug_draft_icon.png|Warning]] For '''EclipseLink 2.4''' (and newer) refer to "Understanding Non-relational Data Sources" in the '''EclipseLink Concepts Guide''': http://www.eclipse.org/eclipselink/documentation/2.4/concepts/nosql.htm
 +
 +
----
 +
 +
 +
 
{{EclipseLink_UserGuide
 
{{EclipseLink_UserGuide
 
|info=y
 
|info=y
|toc=n
+
|toc=y
 
|eclipselink=y
 
|eclipselink=y
 
|eclipselinktype=JPA
 
|eclipselinktype=JPA
Line 22: Line 30:
 
* <code>JTA</code> - JTA managed persistence units are supported, but XA transactions may not be provided unless the NoSQL JCA resource adapter supports JTA.
 
* <code>JTA</code> - JTA managed persistence units are supported, but XA transactions may not be provided unless the NoSQL JCA resource adapter supports JTA.
 
* <code>"javax.jdbc."</code>, <code>"eclipselink.jdbc."</code> - JDBC specific properties are not supported as NoSQL does not use JDBC.
 
* <code>"javax.jdbc."</code>, <code>"eclipselink.jdbc."</code> - JDBC specific properties are not supported as NoSQL does not use JDBC.
 
=== NoSQL Platforms ===
 
EclipseLink provides the following NoSQL platforms and connection specs.  To use a NoSQL platform you must set both the <code>"eclipselink.nosql.connection-spec"</code> to the connection spec class name and the <code>"eclipselink.target-database"</code> to the platform class name.  Each NoSQL platform also supports platform specific properties that can be set using <code>"eclipselink.nosql.property."</code>.
 
 
{|{{BMTableStyle}}
 
|+{{BMTableCaptionStyle}}|NoSQL platforms
 
|-{{BMTHStyle}}
 
| Platform
 
| ConnectionSpec
 
| Properties
 
|-
 
| <code>"org.eclipse.persistence.nosql.adapters.mongo.MongoPlatform"</code>
 
| <code>"org.eclipse.persistence.nosql.adapters.mongo.MongoConnectionSpec"</code>
 
| <code>"eclipselink.nosql.property.mongo.host"</code>,<code>"eclipselink.nosql.property.mongo.port"</code>,<code>"eclipselink.nosql.property.mongo.db"</code>
 
|}
 
  
 
==== MongoDB persistence.xml example ====
 
==== MongoDB persistence.xml example ====
Line 54: Line 47:
 
</persistence>
 
</persistence>
 
</source>
 
</source>
 +
 +
=== NoSQL Platforms ===
 +
EclipseLink provides the following NoSQL platforms and connection specs.  To use a NoSQL platform you must set both the <code>"eclipselink.nosql.connection-spec"</code> to the connection spec class name and the <code>"eclipselink.target-database"</code> to the platform class name.  Each NoSQL platform also supports platform specific properties that can be set using <code>"eclipselink.nosql.property."</code>.
 +
 +
====MongoDB properties====
 +
{|{{BMTableStyle}}
 +
|-{{BMTHStyle}}
 +
| Property
 +
| Value
 +
|-
 +
| <code>"eclipselink.target-database"</code>
 +
| <code>"org.eclipse.persistence.nosql.adapters.mongo.MongoPlatform"</code>
 +
|-
 +
| <code>"eclipselink.connection-spec"</code>
 +
| <code>"org.eclipse.persistence.nosql.adapters.mongo.MongoConnectionSpec"</code>
 +
|-
 +
| <code>"eclipselink.nosql.property.mongo.host"</code>
 +
| comma separated list of MongoDB hosts
 +
|-
 +
| <code>"eclipselink.nosql.property.mongo.port"</code>
 +
| comma separated list of MongoDB host's ports
 +
|-
 +
| <code>"eclipselink.nosql.property.mongo.db"</code>
 +
| MongoDB database
 +
|-
 +
| <code>"eclipselink.nosql.property.mongo.read-preference"</code>
 +
| default ReadPreference (PRIMARY, SECONDARY)
 +
|-
 +
| <code>"eclipselink.nosql.property.mongo.write-concern"</code>
 +
| default WriteConcern (FSYNC_SAFE, JOURNAL_SAFE, MAJORITY, NONE, NORMAL, REPLICAS_SAFE, SAFE)
 +
|-
 +
| <code>"eclipselink.nosql.property.mongo.options"</code>
 +
| default options (integer value)
 +
|}
 +
 +
====Oracle NoSQL properties====
 +
{|{{BMTableStyle}}
 +
|-{{BMTHStyle}}
 +
| Property
 +
| Value
 +
|-
 +
| <code>"eclipselink.target-database"</code>
 +
| <code>"org.eclipse.persistence.nosql.adapters.nosql.OracleNoSQLPlatform"</code>
 +
|-
 +
| <code>"eclipselink.connection-spec"</code>
 +
| <code>"org.eclipse.persistence.nosql.adapters.nosql.OracleNoSQLConnectionSpec"</code>
 +
|-
 +
| <code>"eclipselink.nosql.property.nosql.host"</code>
 +
| comma separated list of Oracle NoSQL hosts
 +
|-
 +
| <code>"eclipselink.nosql.property.nosql.store"</code>
 +
| Oracle NoSQL store
 +
|}
 +
 +
====XML file properties====
 +
{|{{BMTableStyle}}
 +
|-{{BMTHStyle}}
 +
| Property
 +
| Value
 +
|-
 +
| <code>"eclipselink.target-database"</code>
 +
| <code>"org.eclipse.persistence.eis.adapters.xmlfile.XMLFilePlatform"</code>
 +
|-
 +
| <code>"eclipselink.connection-spec"</code>
 +
| <code>"org.eclipse.persistence.eis.adapters.xmlfile.XMLFileEISConnectionSpec"</code>
 +
|-
 +
| <code>"eclipselink.nosql.property.directory"</code>
 +
| directory of xml files
 +
|}
 +
 +
====JMS properties====
 +
{|{{BMTableStyle}}
 +
|-{{BMTHStyle}}
 +
| Property
 +
| Value
 +
|-
 +
| <code>"eclipselink.target-database"</code>
 +
| <code>"org.eclipse.persistence.eis.adapters.jms.JMSPlatform"</code>
 +
|-
 +
| <code>"eclipselink.connection-spec"</code>
 +
| <code>"org.eclipse.persistence.eis.adapters.jms.JMSEISConnectionSpec"</code>
 +
|-
 +
| <code>"eclipselink.nosql.property.factoryURL"</code>
 +
| URL for JMS ConnectionFactory
 +
|-
 +
| <code>"eclipselink.nosql.property.factory"</code>
 +
| JMS ConnectionFactory
 +
|}
 +
 +
====Oracle AQ properties====
 +
{|{{BMTableStyle}}
 +
|-{{BMTHStyle}}
 +
| Property
 +
| Value
 +
|-
 +
| <code>"eclipselink.target-database"</code>
 +
| <code>"org.eclipse.persistence.eis.adapters.aq.AQPlatform"</code>
 +
|-
 +
| <code>"eclipselink.connection-spec"</code>
 +
| <code>"org.eclipse.persistence.eis.adapters.aq.AQEISConnectionSpec"</code>
 +
|-
 +
| <code>"eclipselink.nosql.property.url"</code>
 +
| JDBC URL
 +
|-
 +
| <code>"eclipselink.nosql.property.datasource"</code>
 +
| JDBC datasource URL
 +
|}
  
 
<br>  
 
<br>  
Line 59: Line 159:
  
 
{{EclipseLink_JPA
 
{{EclipseLink_JPA
|previous=[[EclipseLink/UserGuide/JPA/Advanced JPA Development/NoSQL/Configuring|Configuring]]  
+
|previous=[[EclipseLink/UserGuide/JPA/Advanced JPA Development/NoSQL/About|About NoSQL]]  
 
|up=[[EclipseLink/UserGuide/JPA/Advanced JPA Development|Advanced JPA Development]]
 
|up=[[EclipseLink/UserGuide/JPA/Advanced JPA Development|Advanced JPA Development]]
|next=[[EclipseLink/UserGuide/JPA/Advanced JPA Development/NoSQL/Mappings|Mappings]]  
+
|next=[[EclipseLink/UserGuide/JPA/Advanced JPA Development/NoSQL/Configuring|Configuring]]  
 
|version=2.4.0 DRAFT}}
 
|version=2.4.0 DRAFT}}

Latest revision as of 16:19, 15 January 2013


Warning For EclipseLink 2.4 (and newer) refer to "Understanding Non-relational Data Sources" in the EclipseLink Concepts Guide: http://www.eclipse.org/eclipselink/documentation/2.4/concepts/nosql.htm




EclipseLink JPA

Eclipselink-logo.gif
EclipseLink
Website
Download
Community
Mailing ListForumsIRCmattermost
Issues
OpenHelp WantedBug Day
Contribute
Browse Source

NoSQL Persistence Units

NoSQL persistence units are configured the same as JPA persistence units. The persistence.xml is used to define the persistence unit. NoSQL persistence units can be application managed, JTA managed, injected, or created through Persistence the same as regular JPA persistence units. NoSQL persistence units do have some specific persistence unit properties that are required, and have some limitations.

NoSQL defines the following persistence unit properties:

  • "eclipselink.nosql.connection-spec" - this specifies an EISConnectionSpec class name that defines how to connect to the NoSQL data-source.
  • "eclipselink.nosql.connection-factory" - this specifies the JNDI name of a JCA ConnectionFactory, or a JCA ConnectionFactory class name that connects to the NoSQL data-source.
  • "eclipselink.nosql.property." - this prefix is used to pass driver specific properties to the NoSQL connection spec.
  • "eclipselink.target-database" - this is used to set the NoSQL platform class, or use "org.eclipse.persistence.eis.EISPlatform" for a generic platform.

NoSQL persistence units have the following restrictions:

  • <jta-data-source>, <non-jta-data-source> - these are not supported, as they refer to JDBC DataSources.
  • JTA - JTA managed persistence units are supported, but XA transactions may not be provided unless the NoSQL JCA resource adapter supports JTA.
  • "javax.jdbc.", "eclipselink.jdbc." - JDBC specific properties are not supported as NoSQL does not use JDBC.

MongoDB persistence.xml example

<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence persistence_2_0.xsd" version="2.0">
    <persistence-unit name="acme" transaction-type="RESOURCE_LOCAL">
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
        <exclude-unlisted-classes>false</exclude-unlisted-classes>
        <properties>
            <property name="eclipselink.target-database" value="org.eclipse.persistence.nosql.adapters.mongo.MongoPlatform"/>
            <property name="eclipselink.nosql.connection-spec" value="org.eclipse.persistence.nosql.adapters.mongo.MongoConnectionSpec"/>
            <property name="eclipselink.nosql.property.mongo.port" value="27017, 27017"/>
            <property name="eclipselink.nosql.property.mongo.host" value="host1, host2"/>
            <property name="eclipselink.nosql.property.mongo.db" value="acme"/>
        </properties>
    </persistence-unit>
</persistence>

NoSQL Platforms

EclipseLink provides the following NoSQL platforms and connection specs. To use a NoSQL platform you must set both the "eclipselink.nosql.connection-spec" to the connection spec class name and the "eclipselink.target-database" to the platform class name. Each NoSQL platform also supports platform specific properties that can be set using "eclipselink.nosql.property.".

MongoDB properties

Property Value
"eclipselink.target-database" "org.eclipse.persistence.nosql.adapters.mongo.MongoPlatform"
"eclipselink.connection-spec" "org.eclipse.persistence.nosql.adapters.mongo.MongoConnectionSpec"
"eclipselink.nosql.property.mongo.host" comma separated list of MongoDB hosts
"eclipselink.nosql.property.mongo.port" comma separated list of MongoDB host's ports
"eclipselink.nosql.property.mongo.db" MongoDB database
"eclipselink.nosql.property.mongo.read-preference" default ReadPreference (PRIMARY, SECONDARY)
"eclipselink.nosql.property.mongo.write-concern" default WriteConcern (FSYNC_SAFE, JOURNAL_SAFE, MAJORITY, NONE, NORMAL, REPLICAS_SAFE, SAFE)
"eclipselink.nosql.property.mongo.options" default options (integer value)

Oracle NoSQL properties

Property Value
"eclipselink.target-database" "org.eclipse.persistence.nosql.adapters.nosql.OracleNoSQLPlatform"
"eclipselink.connection-spec" "org.eclipse.persistence.nosql.adapters.nosql.OracleNoSQLConnectionSpec"
"eclipselink.nosql.property.nosql.host" comma separated list of Oracle NoSQL hosts
"eclipselink.nosql.property.nosql.store" Oracle NoSQL store

XML file properties

Property Value
"eclipselink.target-database" "org.eclipse.persistence.eis.adapters.xmlfile.XMLFilePlatform"
"eclipselink.connection-spec" "org.eclipse.persistence.eis.adapters.xmlfile.XMLFileEISConnectionSpec"
"eclipselink.nosql.property.directory" directory of xml files

JMS properties

Property Value
"eclipselink.target-database" "org.eclipse.persistence.eis.adapters.jms.JMSPlatform"
"eclipselink.connection-spec" "org.eclipse.persistence.eis.adapters.jms.JMSEISConnectionSpec"
"eclipselink.nosql.property.factoryURL" URL for JMS ConnectionFactory
"eclipselink.nosql.property.factory" JMS ConnectionFactory

Oracle AQ properties

Property Value
"eclipselink.target-database" "org.eclipse.persistence.eis.adapters.aq.AQPlatform"
"eclipselink.connection-spec" "org.eclipse.persistence.eis.adapters.aq.AQEISConnectionSpec"
"eclipselink.nosql.property.url" JDBC URL
"eclipselink.nosql.property.datasource" JDBC datasource URL



Eclipselink-logo.gif
Version: 2.4.0 DRAFT
Other versions...

Copyright © Eclipse Foundation, Inc. All Rights Reserved.