Jump to: navigation, search

Difference between revisions of "EclipseLink/Examples/JPA/NoSQL"

(Ordering Example)
Line 20: Line 20:
 
The source for the example can be found [http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk/examples/org.eclipse.persistence.example.jpa.nosql.mongo/org.eclipse.persistence.example.jpa.nosql.mongo.zip here], or from the EclipseLink SVN [http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk/examples/org.eclipse.persistence.example.jpa.nosql.mongo/ repository].
 
The source for the example can be found [http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk/examples/org.eclipse.persistence.example.jpa.nosql.mongo/org.eclipse.persistence.example.jpa.nosql.mongo.zip here], or from the EclipseLink SVN [http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk/examples/org.eclipse.persistence.example.jpa.nosql.mongo/ repository].
  
 +
The ordering system consists of four classes, Order, OrderLine, Address and Customer.  The Order has a billing and shipping address, many order lines, and a customer.
 +
 +
====Ordering object model====
 +
<source lang="java">
 +
public class Order implements Serializable {
 +
    private String id;
 +
    private String description;
 +
    private double totalCost = 0;
 +
    private Address billingAddress;
 +
    private Address shippingAddress;
 +
    private List<OrderLine> orderLines = new ArrayList<OrderLine>();
 +
    private Customer customer;
 +
    ...
 +
}
 +
</source>
  
 
[[Category:EclipseLink/Example/JPA|NoSQL]]
 
[[Category:EclipseLink/Example/JPA|NoSQL]]

Revision as of 10:19, 26 March 2012

NoSQL

NoSQL is a classification of database systems that do not conform to the relational database or SQL standard. They have various roots, from distributed internet databases, to object databases, XML databases and even legacy databases. They have become recently popular because of their use in large scale distributed databases in Google, Amazon, and Facebook.

There are various NoSQL databases including:

  • Mongo DB
  • Oracle NoSQL
  • Cassandra
  • Google BigTable
  • Couch DB

As of EclipseLink 2.4, EclipseLink has added JPA support for NoSQL databases, initially with support for MongoDB and Oracle NoSQL.

EclipseLink's NoSQL support allow the JPA API and JPA annotations/xml to be used with NoSQL data. EclipseLink also supports several NoSQL specific annotations/xml including @NoSQL that defines a class to map NoSQL data.

EclipseLink's NoSQL support is based on previous EIS support offered since EclipseLink 1.0. EclipseLink's EIS support allowed persisting objects to legacy and non-relational databases. EclipseLink's EIS and NoSQL support uses the Java Connector Architecture (JCA) to access the data-source similar to how EclipseLink's relational support uses JDBC. EclipseLink's NoSQL support is expendable to other NoSQL databases, through the creation of an EclipseLink EISPlatform class and a JCA adapter.

Ordering Example

This example shows how to map and persist an Ordering system object model to a MongoDB NoSQL database.

The source for the example can be found here, or from the EclipseLink SVN repository.

The ordering system consists of four classes, Order, OrderLine, Address and Customer. The Order has a billing and shipping address, many order lines, and a customer.

Ordering object model

public class Order implements Serializable {
    private String id;
    private String description;
    private double totalCost = 0;
    private Address billingAddress;
    private Address shippingAddress;
    private List<OrderLine> orderLines = new ArrayList<OrderLine>();
    private Customer customer;
    ...
}