Mapping to NoSQL data is configured through the EclipseLink
@NoSql annotation, and
<no-sql> XML element.
@NoSql defines the class as mapping to non-relational data.
@NoSql can be specified with
@NoSql annotation defines a
dataType and a
dataFormat attribute. The
dataType attribute is the name for the entity's structure; the meaning of the
dataType is dependent on the NoSQL platform. For MongoDB, it is the collection name that the JSON documents are stored to. For Oracle NoSQL the
dataType is the first part of the major key value. For the XML file adapter it is the file name.
dataFormat attribute specifies the type of structure the data is stored as. The
dataFormat attribute is defined by the
For examples of configuring an application with the
@NoSql annotation, see "@NoSql" in Java Persistence API (JPA) Extensions Reference for EclipseLinkk
NoSQL supports most JPA annotations and others have different restrictions than mapping relational data.
Supported mapping annotations:
@Entity—defines a root level object in the NoSQL data-store.
@Embeddable—defines an object embedded in another object's data structure.
@Version—is supported, but dependent on the NoSQL data-source to validate version write conflicts.
@Embedded—defines a reference that will be embedded in the parent's data structure as a nested structure.
@ElementCollection—defines a collection of values or embeddables that will be embedded in the parent's data structure as a list of nested structures.
@ManyToOne—define a relationship to another root level object stored as a foreign key in the source object's data structure.
@ManyToMany—define a relationship to a collection of other root level object stored as a list of foreign keys in the source object's data structure.
@NamedQuery—is supported on NoSQL data-sources that support querying.
@NamedNativeQuery—is supported on NoSQL data-sources that support native querying. The query language is not SQL, but specific to the NoSQL data-store.
Unsupported mapping annotations:
@SecondaryTable—are not supported, as objects are not mapped to tables, it is replaced by the dataType on the
@Field should be used, as data is not stored in table columns, however
@Column is still allowed, but just the name will be used.
@JoinColumn—is not supported; it is replaced by
@JoinTable—is not required or supported; OneToManys and ManyToManys are stored as collections of Ids embedded in the source object's data structure.
@CollectionTable—is not required or supported; ElementCollections are embedded in the parent object's data structure.
@MapKeyJoinColumn—are not currently supported.
@OrderColumn—are not normally required or supported, as order is normally maintained by the object's data structure.
@TableGenerator—are not directly supported.
@AssociationOverride—are supported with inheritance, but are not supported or required with embedded relationships as embedded objects are nested in their parent object's data structure, not flattened as in the case of relational data.
@BatchFetch—are not supported.