SlideShare ist ein Scribd-Unternehmen logo
1 von 53
codecentric AG 1
Spring Data, Jongo & Co.
Java Persistenz-Frameworks für MongoDB
Tobias.Trelle@codecentric.de @tobiastrelle
codecentric AG 2
Tobias Trelle
- Senior IT Consultant @
codecentric AG (Düsseldorf)
- Organisator MongoDB
Usergruppe Düsseldorf
- Autor MongoDB-Buch
(dpunkt-Verlag)
codecentric AG 3
Where have all my tables gone …
ORM is dead
long live ODM
codecentric AG 4
MongoDB?
 NoSQL-Datenbank / Open Source
 Dokumentenorientiert
 Hochperformant, horizontal skalierbar (scale-out)
 Replication & Sharding out-of-the-box
 Map/Reduce
 Geospatial Indexes / Queries
codecentric AG 5
Grundkonzept MongoDB-Server
Server
Database
Collection
Document
Field
Tabelle
Zeile
Spalte
Relationales
Pendant Aber …
Flexibles
Schema
- Arrays
- Rekursiv
codecentric AG 6
Document
{
title: "MongoDB"
versions: [
{ major: 2, minor: 6},
{ major: 2, minor: 4}
]
}
codecentric AG 8
CRUD = IFUR
insert(…)
find(…), findOne(…)
update(…)
remove()
codecentric AG 9
Java Persistenz mit MongoDB
 MongoDB Java Driver
 Spring Data MongoDB
 Morphia
 Jongo
 EclipseLink for MongoDB

codecentric AG 10
Java Persistenz mit MongoDB
Konnektivität
codecentric AG 11
Use Case
db.order.find( {"items.quantity": ? } )
codecentric AG 12
Mongo Java Driver
codecentric AG 13
MongoDB Drivers
 One wire protocol for all client languages
 A driver implementation per language
 Responsibilities:
 Converting language dependent data structures   BSON
 Generating ObjectId for _id field
 Overview: http://www.mongodb.org/display/DOCS/Drivers
codecentric AG 14
Java Driver
 One JAR w/o further dependencies:
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>2.11.3</version>
</dependency>
 github:
https://github.com/mongodb/mongo-java-driver
codecentric AG 15
Java Driver: API Overview
codecentric AG 16
Java Driver: Connect to MongoDB
import com.mongodb.MongoClient;
// Default: localhost:27017
mongo = new MongoClient();
// Sharding: mongos server
mongo = new MongoClient("mongos01", 4711);
// Replica set
mongo = new MongoClient(Arrays.asList(
new ServerAddress("replicant01", 10001),
new ServerAddress("replicant02", 10002),
new ServerAddress("replicant03", 10003)
));
codecentric AG 17
Java Driver: Database / Collection
import com.mongodb.DB;
import com.mongodb.DBCollection;
DB db = mongo.getDB("test");
DBCollection collection =
db.getCollection("foo");
codecentric AG 18
Java Driver: Documents
import com.mongodb.BasicDBObject;
import com.mongodb.DBObject;
// insert document
DBObject doc = new BasicDBObject();
doc.put("date", new Date());
doc.put("i", 42);
collection.insert(doc);
codecentric AG 19
Java Driver: Queries
import com.mongodb.DBCursor;
DBCursor cursor;
cursor = collection.find(); // all documents
// documents w/ {i: 42}
cursor = collection.find(
new BasicDBObject("i", 42) );
document = cursor.next();
...
codecentric AG 20
Java Driver: Order Use Case
DB db = mongo.getDB("test");
DBCollection collection = db.getCollection("order");
DBObject order;
List<DBObject> items = new ArrayList<DBObject>();
DBObject item;
// order
order = new BasicDBObject();
order.put("date", new Date());
order.put("custInfo" , "Tobias Trelle");
order.put("items", items);
// items
item = new BasicDBObject();
item.put("quantity", 1);
item.put("price", 47.11);
item.put("desc", "Item #1");
items.add(item);
item = new BasicDBObject();
item.put("quantity", 2);
item.put("price", 42.0);
item.put("desc", "Item #2");
items.add(item);
collection.insert(order);
codecentric AG 21
Java Driver: Order Use Case
DB db = mongo.getDB("test");
DBCollection collection = db.getCollection("order");
DBObject query;
DBObject document;
DBCursor cursor;
query = new BasicDBObject("items.quantity", 2);
cursor = collection.find(query);
while ( cursor.hasNext() ) {
document = cursor.next();
println(document);
}
codecentric AG 22
Spring Data
MongoDB
codecentric AG 23
Spring Data MongoDB – Fact Sheet
Vendor Pivotal / SpringSource
License Apache License, Version 2.0
Documentation http://www.springsource.org/spring-data/mongodb
Main Features • Repository Support
• Object/Document Mapping
• Templating
codecentric AG 24
Spring Data
Common patterns for RDBMS and NoSQL data stores
Spring Data
RDBMS MongoDB Neo4j …
Spring Data
JPA
CrudRepository PagingAndSortingRepository
JpaRepository
JPA
JDBC
Spring Data
MongoDB
MongoRepository
MongoTemplate
Spring Data
Neo4j
Spring Data
…
GraphRepository
Neo4jTemplate
Mongo Java Driver
Embedded REST
Quelle: http://www.infoq.com/articles/spring-data-intro
codecentric AG 25
Spring Data MongoDB
Templating
 Resource abstraction
 Configure connections to mongod / mongos node(s)
 Collection lifecycle ( create, drop)
 Map/Reduce / Aggregation
Object Mapping
 Annotation based: @Document, @Field, @Index etc.
 Classes are mapped to collections, Java Objects to documents
Repository Support
 Queries are derived from methods signatures
 Annotated Queries
codecentric AG 26
Spring Data MongoDB: Configuration
<!-- Connection to MongoDB server -->
<mongo:db-factory host="localhost" port="27017" dbname="test" />
<!-- MongoDB Template -->
<bean id="mongoTemplate„
class="org.springframework.data.mongodb.core.MongoTemplate">
<constructor-arg name="mongoDbFactory" ref="mongoDbFactory"/>
</bean>
<!-- Package w/ automagic repositories -->
<mongo:repositories base-package="mongodb" />
codecentric AG 28
Spring Data MongoDB: Object Mapping
public class Order {
@Id private String id;
private Date date;
@Field("custInfo") private String customerInfo;
List<Item> items; ...
}
public class Item {
private int quantity;
private double price;
@Field("desc") private String description;
...
}
codecentric AG 29
Spring Data MongoDB: Repository Support
public interface OrderRepository extends
MongoRepository<Order, String> {
List<Order> findByItemsQuantity(int quantity);
@Query(
value = "{ custInfo: ?0 }",
fields = "{_id:0, items:1}")
List<Order> findOnlyItems(String name);
}
codecentric AG 30
Spring Data MongoDB: Additional Goodies
 Map/Reduce / Aggregation framework
 Index Management
 Support for GridFS
 Geopspatial indexes / queries
 Optimistic Locking
codecentric AG 31
Morphia
codecentric AG 32
Morphia – Fact Sheet
Vendor MongoDB Inc.
License Apache License, Version 2.0
Documentation https://github.com/mongodb/morphia
Main Features • Object/Document Mapping
• Custom Query API
• DAO support
codecentric AG 33
Morphia: Object Mapping
public class Order {
@Id private ObjectId id;
private Date date;
@Property("custInfo") private String customerInfo;
@Embedded List<Item> items;
...
}
public class Item {
private int quantity;
private double price;
@Property("desc") private String description;
...
}
codecentric AG 34
Morphia: Queries
public class OrderDao extends BasicDAO<Order, ObjectId> {
List<Order> findByItemsQuantity(int quantity) {
return
find( createQuery().filter("items.quantity", quantity))
.asList();
}
List<Order> findByItemsPriceGreaterThan(double price) {
return
find( createQuery().field("items.price").greaterThan(price) )
.asList();
}
…
}
codecentric AG 35
Morphia: Queries
public class OrderDao extends BasicDAO<Order, ObjectId> {
 // Projection
 List<Item> findItems(String customerName) {
 List<Order> orders = find(createQuery().
 field("custInfo").equal(customerName).
 retrievedFields(true, "items")
 ).asList();
 // check for null in production code!
 return orders.get(0).getItems();
 }
}
codecentric AG 36
Morphia: Custom query syntax – why?
Morphia Mongo Query
= $eq
!=, <> $neq
>, <, >=,<= $gt, $lt, $gte, $lte
in, nin $in, $nin
elem $elemMatch
… ….
codecentric AG 37
Jongo
codecentric AG 38
Jongo – Fact Sheet
Developer Benoît Guérout, Yves Amsellem
License Apache License, Version 2.0
Documentation http://jongo.org/
Main Features • Object/Document Mapping
• Custom Query API
codecentric AG 39
Jongo: Object Mapping
public class Order {
private ObjectId id;
private Date date;
@JsonProperty("custInfo") private String customerInfo;
List<Item> items;
… }
public class Item {
private int quantity;
private double price;
@JsonProperty("desc") private String description;
…
}
codecentric AG 40
Jongo: Queries
// Java driver API
MongoClient mc = new MongoClient();
DB db = mc.getDB("odm_jongo");
// Jongo API entry point
Jongo jongo = new Jongo(db);
MongoCollection orders = jongo.getCollection("order");
// no DAO needed
Iterable<Order> result =
orders.find("{"items.quantity": #}", 2).as(Order.class);
// Projection
Iterable<X> result =
orders.find().fields("{_id:0, date:1, custInfo:1}").as(X.class);
codecentric AG 41
EclipseLink NoSQL
codecentric AG 42
EclipseLink NoSQL MongoDB – Fact Sheet
Vendor Eclipse Foundation
License Eclipse Public License (EPL)
Documentation http://www.eclipse.org/eclipselink/documentation/2.4/con
cepts/nosql.htm
Main Features • JPA API (Subset)
• JPQL Query Language / Native Queries
codecentric AG 43
EclipseLink NoSQL
 Implements JPA API (subset)
 JP-QL query are translated to native
datastore queries
 Oracle NoSQL, MongoDB
codecentric AG 44
EclipseLink NoSQL MongoDB: Configuration
<persistence version="2.0" …>
<persistence-unit name="mongodb">
<class>hibernate.Order</class>
<class>hibernate.Item</class>
<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"/>
<property name="eclipselink.nosql.property.mongo.host" value="127.0.0.1"/>
<property name="eclipselink.nosql.property.mongo.db" value="odm_eclipselink"/>
<property name="eclipselink.logging.level" value="FINE"/>
</properties>
</persistence-unit>
</persistence>
codecentric AG 45
EclipseLink NoSQL MongoDB : Object Mapping
@Entity
@NoSql(dataFormat=DataFormatType.MAPPED)
public class Order {
@GeneratedValue
@Id
@Field(name = "_id")
private String id;
private Date date;
@Column(name = "custInfo") private String customerInfo;
@ElementCollection
private List<Item> items;
codecentric AG 46
EclipseLink NoSQL MongoDB : Object Mapping
@Embeddable
@NoSql(dataFormat=DataFormatType.MAPPED)
public class Item {
private int quantity;
private double price;
@Column(name="desc") private String description;
...
codecentric AG 47
EclipseLink NoSQL MongoDB : Queries
// JPQL
Order order = em.createQuery(
 "SELECT o FROM Order o JOIN o.items i WHERE
i.quantity = 2",
 Order.class).getSingleResult();
// native
Order order = (Order)em.createNativeQuery(
 "db.ORDER.findOne({_id: "" + id + ""})",
 Order.class).getSingleResult();
codecentric AG 48
EclipseLink NoSQL MongoDB
 Problems w/ nested native queries
Uses relational API, TX required(?)
codecentric AG 49
More JPA Providers for MongoDB
 Hibernate OGM
 Very early beta
 No support for queries
 Data Nucleus
codecentric AG 50
Hibernate OGM: OgmEntityManager
codecentric AG 51
Judge yourself …
Spring Data MongoDB
https://github.com/ttrelle/spring-data-examples
Morphia
https://github.com/ttrelle/morphia-mongodb-examples
Jongo
https://github.com/ttrelle/jongo-examples
EclipseLink
https://github.com/ttrelle/eclipselink-mongodb-examples
codecentric AG 52
Summary
ODM
Annotations
Queries
Java Driver -- Nested BasicDBObject‘s
Spring Data MongoDB Custom Interface w/
- derived queries
- Native queries
EclipseLink JPA + Custom JPQL: @Named(Native)Query +
EntityManager
Jongo Jackson JSON queries via collection
wrapper
Morphia Custom BasicDAO super class w/ 2
flavours of fluent API
codecentric AG 53
Which one should I use?
EclipseLink
Spring Data
MongoDB
MongoDB Java Driver
Morphia
JPA
JDBC
MongoDB
Jongo
- Ready for production
- Supported by MongoDB Inc.
Mature
- Ready for production
- Active community
- API mismatch
The „better“ driver
codecentric AG 54
MongoDB User Group Düsseldorf
https://www.xing.com/net/mongodb-dus
@MongoDUS
MUG Düsseldorf
codecentric AG 55
QUESTIONS?
Tobias Trelle
codecentric AG
Merscheider Str. 1
42699 Solingen
tel +49 (0) 212.233628.47
fax +49 (0) 212.233628.79
mail Tobias.Trelle@codecentric.de
twitter @tobiastrelle
www.codecentric.de
blog.codecentric.de/en/author/tobias-trelle
www.xing.com/net/mongodb-dus

Weitere ähnliche Inhalte

Was ist angesagt?

Java Development with MongoDB
Java Development with MongoDBJava Development with MongoDB
Java Development with MongoDBScott Hernandez
 
Getting Started with MongoDB and NodeJS
Getting Started with MongoDB and NodeJSGetting Started with MongoDB and NodeJS
Getting Started with MongoDB and NodeJSMongoDB
 
Webinar: Building Your First App with MongoDB and Java
Webinar: Building Your First App with MongoDB and JavaWebinar: Building Your First App with MongoDB and Java
Webinar: Building Your First App with MongoDB and JavaMongoDB
 
Hadoop - MongoDB Webinar June 2014
Hadoop - MongoDB Webinar June 2014Hadoop - MongoDB Webinar June 2014
Hadoop - MongoDB Webinar June 2014MongoDB
 
Introduction to Restkit
Introduction to RestkitIntroduction to Restkit
Introduction to Restkitpetertmarks
 
Benefits of Using MongoDB Over RDBMS (At An Evening with MongoDB Minneapolis ...
Benefits of Using MongoDB Over RDBMS (At An Evening with MongoDB Minneapolis ...Benefits of Using MongoDB Over RDBMS (At An Evening with MongoDB Minneapolis ...
Benefits of Using MongoDB Over RDBMS (At An Evening with MongoDB Minneapolis ...MongoDB
 
MongoDB .local Toronto 2019: Using Change Streams to Keep Up with Your Data
MongoDB .local Toronto 2019: Using Change Streams to Keep Up with Your DataMongoDB .local Toronto 2019: Using Change Streams to Keep Up with Your Data
MongoDB .local Toronto 2019: Using Change Streams to Keep Up with Your DataMongoDB
 
Back to Basics Webinar 5: Introduction to the Aggregation Framework
Back to Basics Webinar 5: Introduction to the Aggregation FrameworkBack to Basics Webinar 5: Introduction to the Aggregation Framework
Back to Basics Webinar 5: Introduction to the Aggregation FrameworkMongoDB
 
Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...
Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...
Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...MongoDB
 
MongoDB: Comparing WiredTiger In-Memory Engine to Redis
MongoDB: Comparing WiredTiger In-Memory Engine to RedisMongoDB: Comparing WiredTiger In-Memory Engine to Redis
MongoDB: Comparing WiredTiger In-Memory Engine to RedisJason Terpko
 
NoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love StoryNoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love StoryAlexandre Morgaut
 
Joins and Other Aggregation Enhancements Coming in MongoDB 3.2
Joins and Other Aggregation Enhancements Coming in MongoDB 3.2Joins and Other Aggregation Enhancements Coming in MongoDB 3.2
Joins and Other Aggregation Enhancements Coming in MongoDB 3.2MongoDB
 
Data Management 3: Bulletproof Data Management
Data Management 3: Bulletproof Data ManagementData Management 3: Bulletproof Data Management
Data Management 3: Bulletproof Data ManagementMongoDB
 
Faites évoluer votre accès aux données avec MongoDB Stitch
Faites évoluer votre accès aux données avec MongoDB StitchFaites évoluer votre accès aux données avec MongoDB Stitch
Faites évoluer votre accès aux données avec MongoDB StitchMongoDB
 
MongoDB - External Authentication
MongoDB - External AuthenticationMongoDB - External Authentication
MongoDB - External AuthenticationJason Terpko
 
Open Policy Agent (OPA) と Kubernetes Policy
Open Policy Agent (OPA) と Kubernetes PolicyOpen Policy Agent (OPA) と Kubernetes Policy
Open Policy Agent (OPA) と Kubernetes PolicyMotonori Shindo
 
PistonHead's use of MongoDB for Analytics
PistonHead's use of MongoDB for AnalyticsPistonHead's use of MongoDB for Analytics
PistonHead's use of MongoDB for AnalyticsAndrew Morgan
 
2014 bigdatacamp asya_kamsky
2014 bigdatacamp asya_kamsky2014 bigdatacamp asya_kamsky
2014 bigdatacamp asya_kamskyData Con LA
 
FIWARE Global Summit - Hands-On NGSI-LD
FIWARE Global Summit - Hands-On NGSI-LDFIWARE Global Summit - Hands-On NGSI-LD
FIWARE Global Summit - Hands-On NGSI-LDFIWARE
 

Was ist angesagt? (20)

Java Development with MongoDB
Java Development with MongoDBJava Development with MongoDB
Java Development with MongoDB
 
Getting Started with MongoDB and NodeJS
Getting Started with MongoDB and NodeJSGetting Started with MongoDB and NodeJS
Getting Started with MongoDB and NodeJS
 
Webinar: Building Your First App with MongoDB and Java
Webinar: Building Your First App with MongoDB and JavaWebinar: Building Your First App with MongoDB and Java
Webinar: Building Your First App with MongoDB and Java
 
MongodB Internals
MongodB InternalsMongodB Internals
MongodB Internals
 
Hadoop - MongoDB Webinar June 2014
Hadoop - MongoDB Webinar June 2014Hadoop - MongoDB Webinar June 2014
Hadoop - MongoDB Webinar June 2014
 
Introduction to Restkit
Introduction to RestkitIntroduction to Restkit
Introduction to Restkit
 
Benefits of Using MongoDB Over RDBMS (At An Evening with MongoDB Minneapolis ...
Benefits of Using MongoDB Over RDBMS (At An Evening with MongoDB Minneapolis ...Benefits of Using MongoDB Over RDBMS (At An Evening with MongoDB Minneapolis ...
Benefits of Using MongoDB Over RDBMS (At An Evening with MongoDB Minneapolis ...
 
MongoDB .local Toronto 2019: Using Change Streams to Keep Up with Your Data
MongoDB .local Toronto 2019: Using Change Streams to Keep Up with Your DataMongoDB .local Toronto 2019: Using Change Streams to Keep Up with Your Data
MongoDB .local Toronto 2019: Using Change Streams to Keep Up with Your Data
 
Back to Basics Webinar 5: Introduction to the Aggregation Framework
Back to Basics Webinar 5: Introduction to the Aggregation FrameworkBack to Basics Webinar 5: Introduction to the Aggregation Framework
Back to Basics Webinar 5: Introduction to the Aggregation Framework
 
Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...
Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...
Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...
 
MongoDB: Comparing WiredTiger In-Memory Engine to Redis
MongoDB: Comparing WiredTiger In-Memory Engine to RedisMongoDB: Comparing WiredTiger In-Memory Engine to Redis
MongoDB: Comparing WiredTiger In-Memory Engine to Redis
 
NoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love StoryNoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love Story
 
Joins and Other Aggregation Enhancements Coming in MongoDB 3.2
Joins and Other Aggregation Enhancements Coming in MongoDB 3.2Joins and Other Aggregation Enhancements Coming in MongoDB 3.2
Joins and Other Aggregation Enhancements Coming in MongoDB 3.2
 
Data Management 3: Bulletproof Data Management
Data Management 3: Bulletproof Data ManagementData Management 3: Bulletproof Data Management
Data Management 3: Bulletproof Data Management
 
Faites évoluer votre accès aux données avec MongoDB Stitch
Faites évoluer votre accès aux données avec MongoDB StitchFaites évoluer votre accès aux données avec MongoDB Stitch
Faites évoluer votre accès aux données avec MongoDB Stitch
 
MongoDB - External Authentication
MongoDB - External AuthenticationMongoDB - External Authentication
MongoDB - External Authentication
 
Open Policy Agent (OPA) と Kubernetes Policy
Open Policy Agent (OPA) と Kubernetes PolicyOpen Policy Agent (OPA) と Kubernetes Policy
Open Policy Agent (OPA) と Kubernetes Policy
 
PistonHead's use of MongoDB for Analytics
PistonHead's use of MongoDB for AnalyticsPistonHead's use of MongoDB for Analytics
PistonHead's use of MongoDB for Analytics
 
2014 bigdatacamp asya_kamsky
2014 bigdatacamp asya_kamsky2014 bigdatacamp asya_kamsky
2014 bigdatacamp asya_kamsky
 
FIWARE Global Summit - Hands-On NGSI-LD
FIWARE Global Summit - Hands-On NGSI-LDFIWARE Global Summit - Hands-On NGSI-LD
FIWARE Global Summit - Hands-On NGSI-LD
 

Andere mochten auch

Spring 4 final xtr_presentation
Spring 4 final xtr_presentationSpring 4 final xtr_presentation
Spring 4 final xtr_presentationsourabh aggarwal
 
jpa-hibernate-presentation
jpa-hibernate-presentationjpa-hibernate-presentation
jpa-hibernate-presentationJohn Slick
 
ORM, JPA, & Hibernate Overview
ORM, JPA, & Hibernate OverviewORM, JPA, & Hibernate Overview
ORM, JPA, & Hibernate OverviewBrett Meyer
 
Java Persistence API (JPA) Step By Step
Java Persistence API (JPA) Step By StepJava Persistence API (JPA) Step By Step
Java Persistence API (JPA) Step By StepGuo Albert
 
Awnex presentation
Awnex presentationAwnex presentation
Awnex presentationjpanek13
 
Presentation SMWS
Presentation SMWSPresentation SMWS
Presentation SMWSgoritz
 
Project titles for EEE and ECE
Project titles for  EEE and  ECEProject titles for  EEE and  ECE
Project titles for EEE and ECESenthil Kumar
 
Ilan Goren @ German Israel Congress 2013, Berlin
Ilan Goren @ German Israel Congress 2013, BerlinIlan Goren @ German Israel Congress 2013, Berlin
Ilan Goren @ German Israel Congress 2013, Berlinilangoren
 
2012 Media Highlights
2012 Media Highlights2012 Media Highlights
2012 Media Highlightsmeatconamibia
 
Como ser un gran maestro
Como ser un gran maestroComo ser un gran maestro
Como ser un gran maestroWerton Bastos
 

Andere mochten auch (18)

MongoDB + Spring
MongoDB + SpringMongoDB + Spring
MongoDB + Spring
 
Spring 4 final xtr_presentation
Spring 4 final xtr_presentationSpring 4 final xtr_presentation
Spring 4 final xtr_presentation
 
jpa-hibernate-presentation
jpa-hibernate-presentationjpa-hibernate-presentation
jpa-hibernate-presentation
 
ORM, JPA, & Hibernate Overview
ORM, JPA, & Hibernate OverviewORM, JPA, & Hibernate Overview
ORM, JPA, & Hibernate Overview
 
Java Persistence API (JPA) Step By Step
Java Persistence API (JPA) Step By StepJava Persistence API (JPA) Step By Step
Java Persistence API (JPA) Step By Step
 
Awnex presentation
Awnex presentationAwnex presentation
Awnex presentation
 
Presentation SMWS
Presentation SMWSPresentation SMWS
Presentation SMWS
 
Project titles for EEE and ECE
Project titles for  EEE and  ECEProject titles for  EEE and  ECE
Project titles for EEE and ECE
 
Drgorad em- project
Drgorad  em- projectDrgorad  em- project
Drgorad em- project
 
Sante1 slideshare
Sante1 slideshareSante1 slideshare
Sante1 slideshare
 
Ilan Goren @ German Israel Congress 2013, Berlin
Ilan Goren @ German Israel Congress 2013, BerlinIlan Goren @ German Israel Congress 2013, Berlin
Ilan Goren @ German Israel Congress 2013, Berlin
 
2012 Media Highlights
2012 Media Highlights2012 Media Highlights
2012 Media Highlights
 
Hari kantin sekolah
Hari kantin sekolahHari kantin sekolah
Hari kantin sekolah
 
Emi3
Emi3Emi3
Emi3
 
Ccfl
CcflCcfl
Ccfl
 
Como ser un gran maestro
Como ser un gran maestroComo ser un gran maestro
Como ser un gran maestro
 
Entrepreneurship
EntrepreneurshipEntrepreneurship
Entrepreneurship
 
Power
PowerPower
Power
 

Ähnlich wie Spring Data, Jongo & Co.

Spring Data MongoDB 介紹
Spring Data MongoDB 介紹Spring Data MongoDB 介紹
Spring Data MongoDB 介紹Kuo-Chun Su
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDBChun-Kai Wang
 
Java Development with MongoDB (James Williams)
Java Development with MongoDB (James Williams)Java Development with MongoDB (James Williams)
Java Development with MongoDB (James Williams)MongoSF
 
Back to Basics, webinar 2: La tua prima applicazione MongoDB
Back to Basics, webinar 2: La tua prima applicazione MongoDBBack to Basics, webinar 2: La tua prima applicazione MongoDB
Back to Basics, webinar 2: La tua prima applicazione MongoDBMongoDB
 
Dev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBDev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBMongoDB
 
Dev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBDev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBMongoDB
 
Back to Basics Webinar 2 - Your First MongoDB Application
Back to  Basics Webinar 2 - Your First MongoDB ApplicationBack to  Basics Webinar 2 - Your First MongoDB Application
Back to Basics Webinar 2 - Your First MongoDB ApplicationJoe Drumgoole
 
Back to Basics Webinar 2: Your First MongoDB Application
Back to Basics Webinar 2: Your First MongoDB ApplicationBack to Basics Webinar 2: Your First MongoDB Application
Back to Basics Webinar 2: Your First MongoDB ApplicationMongoDB
 
MongoDB.local Paris Keynote
MongoDB.local Paris KeynoteMongoDB.local Paris Keynote
MongoDB.local Paris KeynoteMongoDB
 
Dev Jumpstart: Building Your First App
Dev Jumpstart: Building Your First AppDev Jumpstart: Building Your First App
Dev Jumpstart: Building Your First AppMongoDB
 
Implementing a build manager in Ada
Implementing a build manager in AdaImplementing a build manager in Ada
Implementing a build manager in AdaStephane Carrez
 
Webinar: Building Your First App in Node.js
Webinar: Building Your First App in Node.jsWebinar: Building Your First App in Node.js
Webinar: Building Your First App in Node.jsMongoDB
 
Webinar: Building Your First App in Node.js
Webinar: Building Your First App in Node.jsWebinar: Building Your First App in Node.js
Webinar: Building Your First App in Node.jsMongoDB
 
MongoDB - How to model and extract your data
MongoDB - How to model and extract your dataMongoDB - How to model and extract your data
MongoDB - How to model and extract your dataFrancesco Lo Franco
 
Mongodb ExpressJS HandlebarsJS NodeJS FullStack
Mongodb ExpressJS HandlebarsJS NodeJS FullStackMongodb ExpressJS HandlebarsJS NodeJS FullStack
Mongodb ExpressJS HandlebarsJS NodeJS FullStackNarendranath Reddy
 
IndexedDB and Push Notifications in Progressive Web Apps
IndexedDB and Push Notifications in Progressive Web AppsIndexedDB and Push Notifications in Progressive Web Apps
IndexedDB and Push Notifications in Progressive Web AppsAdégòkè Obasá
 
Test Automation for NoSQL Databases
Test Automation for NoSQL DatabasesTest Automation for NoSQL Databases
Test Automation for NoSQL DatabasesTobias Trelle
 

Ähnlich wie Spring Data, Jongo & Co. (20)

Spring Data MongoDB 介紹
Spring Data MongoDB 介紹Spring Data MongoDB 介紹
Spring Data MongoDB 介紹
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
Green dao
Green daoGreen dao
Green dao
 
Java Development with MongoDB (James Williams)
Java Development with MongoDB (James Williams)Java Development with MongoDB (James Williams)
Java Development with MongoDB (James Williams)
 
Back to Basics, webinar 2: La tua prima applicazione MongoDB
Back to Basics, webinar 2: La tua prima applicazione MongoDBBack to Basics, webinar 2: La tua prima applicazione MongoDB
Back to Basics, webinar 2: La tua prima applicazione MongoDB
 
Dev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBDev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDB
 
Dev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBDev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDB
 
Back to Basics Webinar 2 - Your First MongoDB Application
Back to  Basics Webinar 2 - Your First MongoDB ApplicationBack to  Basics Webinar 2 - Your First MongoDB Application
Back to Basics Webinar 2 - Your First MongoDB Application
 
Back to Basics Webinar 2: Your First MongoDB Application
Back to Basics Webinar 2: Your First MongoDB ApplicationBack to Basics Webinar 2: Your First MongoDB Application
Back to Basics Webinar 2: Your First MongoDB Application
 
An introduction to MongoDB
An introduction to MongoDBAn introduction to MongoDB
An introduction to MongoDB
 
MongoDB and Node.js
MongoDB and Node.jsMongoDB and Node.js
MongoDB and Node.js
 
MongoDB.local Paris Keynote
MongoDB.local Paris KeynoteMongoDB.local Paris Keynote
MongoDB.local Paris Keynote
 
Dev Jumpstart: Building Your First App
Dev Jumpstart: Building Your First AppDev Jumpstart: Building Your First App
Dev Jumpstart: Building Your First App
 
Implementing a build manager in Ada
Implementing a build manager in AdaImplementing a build manager in Ada
Implementing a build manager in Ada
 
Webinar: Building Your First App in Node.js
Webinar: Building Your First App in Node.jsWebinar: Building Your First App in Node.js
Webinar: Building Your First App in Node.js
 
Webinar: Building Your First App in Node.js
Webinar: Building Your First App in Node.jsWebinar: Building Your First App in Node.js
Webinar: Building Your First App in Node.js
 
MongoDB - How to model and extract your data
MongoDB - How to model and extract your dataMongoDB - How to model and extract your data
MongoDB - How to model and extract your data
 
Mongodb ExpressJS HandlebarsJS NodeJS FullStack
Mongodb ExpressJS HandlebarsJS NodeJS FullStackMongodb ExpressJS HandlebarsJS NodeJS FullStack
Mongodb ExpressJS HandlebarsJS NodeJS FullStack
 
IndexedDB and Push Notifications in Progressive Web Apps
IndexedDB and Push Notifications in Progressive Web AppsIndexedDB and Push Notifications in Progressive Web Apps
IndexedDB and Push Notifications in Progressive Web Apps
 
Test Automation for NoSQL Databases
Test Automation for NoSQL DatabasesTest Automation for NoSQL Databases
Test Automation for NoSQL Databases
 

Mehr von Tobias Trelle

TDD mit JUnit und Mockito
TDD mit JUnit und MockitoTDD mit JUnit und Mockito
TDD mit JUnit und MockitoTobias Trelle
 
NoSQL - Einführung in Graphen-Datenbanken mit Neo4j
NoSQL - Einführung in Graphen-Datenbanken mit Neo4jNoSQL - Einführung in Graphen-Datenbanken mit Neo4j
NoSQL - Einführung in Graphen-Datenbanken mit Neo4jTobias Trelle
 
Einführung in NoSQL-Datenbanken
Einführung in NoSQL-DatenbankenEinführung in NoSQL-Datenbanken
Einführung in NoSQL-DatenbankenTobias Trelle
 
MongoDB - Riesige Datenmengen schemafrei verwalten
MongoDB - Riesige Datenmengen schemafrei verwaltenMongoDB - Riesige Datenmengen schemafrei verwalten
MongoDB - Riesige Datenmengen schemafrei verwaltenTobias Trelle
 
Morphia, Spring Data & Co
Morphia, Spring Data & CoMorphia, Spring Data & Co
Morphia, Spring Data & CoTobias Trelle
 
An introduction to MongoDB and Ruby
An introduction to MongoDB and RubyAn introduction to MongoDB and Ruby
An introduction to MongoDB and RubyTobias Trelle
 
OOP 2013: Praktische Einführung in MongoDB
OOP 2013: Praktische Einführung in MongoDBOOP 2013: Praktische Einführung in MongoDB
OOP 2013: Praktische Einführung in MongoDBTobias Trelle
 
MongoDB Munich 2012: Spring Data MongoDB
MongoDB Munich 2012: Spring Data MongoDBMongoDB Munich 2012: Spring Data MongoDB
MongoDB Munich 2012: Spring Data MongoDBTobias Trelle
 
MongoDB Live Hacking
MongoDB Live HackingMongoDB Live Hacking
MongoDB Live HackingTobias Trelle
 

Mehr von Tobias Trelle (10)

TDD mit JUnit und Mockito
TDD mit JUnit und MockitoTDD mit JUnit und Mockito
TDD mit JUnit und Mockito
 
NoSQL - Einführung in Graphen-Datenbanken mit Neo4j
NoSQL - Einführung in Graphen-Datenbanken mit Neo4jNoSQL - Einführung in Graphen-Datenbanken mit Neo4j
NoSQL - Einführung in Graphen-Datenbanken mit Neo4j
 
Einführung in NoSQL-Datenbanken
Einführung in NoSQL-DatenbankenEinführung in NoSQL-Datenbanken
Einführung in NoSQL-Datenbanken
 
MongoDB Einführung
MongoDB EinführungMongoDB Einführung
MongoDB Einführung
 
MongoDB - Riesige Datenmengen schemafrei verwalten
MongoDB - Riesige Datenmengen schemafrei verwaltenMongoDB - Riesige Datenmengen schemafrei verwalten
MongoDB - Riesige Datenmengen schemafrei verwalten
 
Morphia, Spring Data & Co
Morphia, Spring Data & CoMorphia, Spring Data & Co
Morphia, Spring Data & Co
 
An introduction to MongoDB and Ruby
An introduction to MongoDB and RubyAn introduction to MongoDB and Ruby
An introduction to MongoDB and Ruby
 
OOP 2013: Praktische Einführung in MongoDB
OOP 2013: Praktische Einführung in MongoDBOOP 2013: Praktische Einführung in MongoDB
OOP 2013: Praktische Einführung in MongoDB
 
MongoDB Munich 2012: Spring Data MongoDB
MongoDB Munich 2012: Spring Data MongoDBMongoDB Munich 2012: Spring Data MongoDB
MongoDB Munich 2012: Spring Data MongoDB
 
MongoDB Live Hacking
MongoDB Live HackingMongoDB Live Hacking
MongoDB Live Hacking
 

Kürzlich hochgeladen

Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 

Kürzlich hochgeladen (20)

Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 

Spring Data, Jongo & Co.

  • 1. codecentric AG 1 Spring Data, Jongo & Co. Java Persistenz-Frameworks für MongoDB Tobias.Trelle@codecentric.de @tobiastrelle
  • 2. codecentric AG 2 Tobias Trelle - Senior IT Consultant @ codecentric AG (Düsseldorf) - Organisator MongoDB Usergruppe Düsseldorf - Autor MongoDB-Buch (dpunkt-Verlag)
  • 3. codecentric AG 3 Where have all my tables gone … ORM is dead long live ODM
  • 4. codecentric AG 4 MongoDB?  NoSQL-Datenbank / Open Source  Dokumentenorientiert  Hochperformant, horizontal skalierbar (scale-out)  Replication & Sharding out-of-the-box  Map/Reduce  Geospatial Indexes / Queries
  • 5. codecentric AG 5 Grundkonzept MongoDB-Server Server Database Collection Document Field Tabelle Zeile Spalte Relationales Pendant Aber … Flexibles Schema - Arrays - Rekursiv
  • 6. codecentric AG 6 Document { title: "MongoDB" versions: [ { major: 2, minor: 6}, { major: 2, minor: 4} ] }
  • 7. codecentric AG 8 CRUD = IFUR insert(…) find(…), findOne(…) update(…) remove()
  • 8. codecentric AG 9 Java Persistenz mit MongoDB  MongoDB Java Driver  Spring Data MongoDB  Morphia  Jongo  EclipseLink for MongoDB 
  • 9. codecentric AG 10 Java Persistenz mit MongoDB Konnektivität
  • 10. codecentric AG 11 Use Case db.order.find( {"items.quantity": ? } )
  • 11. codecentric AG 12 Mongo Java Driver
  • 12. codecentric AG 13 MongoDB Drivers  One wire protocol for all client languages  A driver implementation per language  Responsibilities:  Converting language dependent data structures   BSON  Generating ObjectId for _id field  Overview: http://www.mongodb.org/display/DOCS/Drivers
  • 13. codecentric AG 14 Java Driver  One JAR w/o further dependencies: <dependency> <groupId>org.mongodb</groupId> <artifactId>mongo-java-driver</artifactId> <version>2.11.3</version> </dependency>  github: https://github.com/mongodb/mongo-java-driver
  • 14. codecentric AG 15 Java Driver: API Overview
  • 15. codecentric AG 16 Java Driver: Connect to MongoDB import com.mongodb.MongoClient; // Default: localhost:27017 mongo = new MongoClient(); // Sharding: mongos server mongo = new MongoClient("mongos01", 4711); // Replica set mongo = new MongoClient(Arrays.asList( new ServerAddress("replicant01", 10001), new ServerAddress("replicant02", 10002), new ServerAddress("replicant03", 10003) ));
  • 16. codecentric AG 17 Java Driver: Database / Collection import com.mongodb.DB; import com.mongodb.DBCollection; DB db = mongo.getDB("test"); DBCollection collection = db.getCollection("foo");
  • 17. codecentric AG 18 Java Driver: Documents import com.mongodb.BasicDBObject; import com.mongodb.DBObject; // insert document DBObject doc = new BasicDBObject(); doc.put("date", new Date()); doc.put("i", 42); collection.insert(doc);
  • 18. codecentric AG 19 Java Driver: Queries import com.mongodb.DBCursor; DBCursor cursor; cursor = collection.find(); // all documents // documents w/ {i: 42} cursor = collection.find( new BasicDBObject("i", 42) ); document = cursor.next(); ...
  • 19. codecentric AG 20 Java Driver: Order Use Case DB db = mongo.getDB("test"); DBCollection collection = db.getCollection("order"); DBObject order; List<DBObject> items = new ArrayList<DBObject>(); DBObject item; // order order = new BasicDBObject(); order.put("date", new Date()); order.put("custInfo" , "Tobias Trelle"); order.put("items", items); // items item = new BasicDBObject(); item.put("quantity", 1); item.put("price", 47.11); item.put("desc", "Item #1"); items.add(item); item = new BasicDBObject(); item.put("quantity", 2); item.put("price", 42.0); item.put("desc", "Item #2"); items.add(item); collection.insert(order);
  • 20. codecentric AG 21 Java Driver: Order Use Case DB db = mongo.getDB("test"); DBCollection collection = db.getCollection("order"); DBObject query; DBObject document; DBCursor cursor; query = new BasicDBObject("items.quantity", 2); cursor = collection.find(query); while ( cursor.hasNext() ) { document = cursor.next(); println(document); }
  • 21. codecentric AG 22 Spring Data MongoDB
  • 22. codecentric AG 23 Spring Data MongoDB – Fact Sheet Vendor Pivotal / SpringSource License Apache License, Version 2.0 Documentation http://www.springsource.org/spring-data/mongodb Main Features • Repository Support • Object/Document Mapping • Templating
  • 23. codecentric AG 24 Spring Data Common patterns for RDBMS and NoSQL data stores Spring Data RDBMS MongoDB Neo4j … Spring Data JPA CrudRepository PagingAndSortingRepository JpaRepository JPA JDBC Spring Data MongoDB MongoRepository MongoTemplate Spring Data Neo4j Spring Data … GraphRepository Neo4jTemplate Mongo Java Driver Embedded REST Quelle: http://www.infoq.com/articles/spring-data-intro
  • 24. codecentric AG 25 Spring Data MongoDB Templating  Resource abstraction  Configure connections to mongod / mongos node(s)  Collection lifecycle ( create, drop)  Map/Reduce / Aggregation Object Mapping  Annotation based: @Document, @Field, @Index etc.  Classes are mapped to collections, Java Objects to documents Repository Support  Queries are derived from methods signatures  Annotated Queries
  • 25. codecentric AG 26 Spring Data MongoDB: Configuration <!-- Connection to MongoDB server --> <mongo:db-factory host="localhost" port="27017" dbname="test" /> <!-- MongoDB Template --> <bean id="mongoTemplate„ class="org.springframework.data.mongodb.core.MongoTemplate"> <constructor-arg name="mongoDbFactory" ref="mongoDbFactory"/> </bean> <!-- Package w/ automagic repositories --> <mongo:repositories base-package="mongodb" />
  • 26. codecentric AG 28 Spring Data MongoDB: Object Mapping public class Order { @Id private String id; private Date date; @Field("custInfo") private String customerInfo; List<Item> items; ... } public class Item { private int quantity; private double price; @Field("desc") private String description; ... }
  • 27. codecentric AG 29 Spring Data MongoDB: Repository Support public interface OrderRepository extends MongoRepository<Order, String> { List<Order> findByItemsQuantity(int quantity); @Query( value = "{ custInfo: ?0 }", fields = "{_id:0, items:1}") List<Order> findOnlyItems(String name); }
  • 28. codecentric AG 30 Spring Data MongoDB: Additional Goodies  Map/Reduce / Aggregation framework  Index Management  Support for GridFS  Geopspatial indexes / queries  Optimistic Locking
  • 30. codecentric AG 32 Morphia – Fact Sheet Vendor MongoDB Inc. License Apache License, Version 2.0 Documentation https://github.com/mongodb/morphia Main Features • Object/Document Mapping • Custom Query API • DAO support
  • 31. codecentric AG 33 Morphia: Object Mapping public class Order { @Id private ObjectId id; private Date date; @Property("custInfo") private String customerInfo; @Embedded List<Item> items; ... } public class Item { private int quantity; private double price; @Property("desc") private String description; ... }
  • 32. codecentric AG 34 Morphia: Queries public class OrderDao extends BasicDAO<Order, ObjectId> { List<Order> findByItemsQuantity(int quantity) { return find( createQuery().filter("items.quantity", quantity)) .asList(); } List<Order> findByItemsPriceGreaterThan(double price) { return find( createQuery().field("items.price").greaterThan(price) ) .asList(); } … }
  • 33. codecentric AG 35 Morphia: Queries public class OrderDao extends BasicDAO<Order, ObjectId> {  // Projection  List<Item> findItems(String customerName) {  List<Order> orders = find(createQuery().  field("custInfo").equal(customerName).  retrievedFields(true, "items")  ).asList();  // check for null in production code!  return orders.get(0).getItems();  } }
  • 34. codecentric AG 36 Morphia: Custom query syntax – why? Morphia Mongo Query = $eq !=, <> $neq >, <, >=,<= $gt, $lt, $gte, $lte in, nin $in, $nin elem $elemMatch … ….
  • 36. codecentric AG 38 Jongo – Fact Sheet Developer Benoît Guérout, Yves Amsellem License Apache License, Version 2.0 Documentation http://jongo.org/ Main Features • Object/Document Mapping • Custom Query API
  • 37. codecentric AG 39 Jongo: Object Mapping public class Order { private ObjectId id; private Date date; @JsonProperty("custInfo") private String customerInfo; List<Item> items; … } public class Item { private int quantity; private double price; @JsonProperty("desc") private String description; … }
  • 38. codecentric AG 40 Jongo: Queries // Java driver API MongoClient mc = new MongoClient(); DB db = mc.getDB("odm_jongo"); // Jongo API entry point Jongo jongo = new Jongo(db); MongoCollection orders = jongo.getCollection("order"); // no DAO needed Iterable<Order> result = orders.find("{"items.quantity": #}", 2).as(Order.class); // Projection Iterable<X> result = orders.find().fields("{_id:0, date:1, custInfo:1}").as(X.class);
  • 40. codecentric AG 42 EclipseLink NoSQL MongoDB – Fact Sheet Vendor Eclipse Foundation License Eclipse Public License (EPL) Documentation http://www.eclipse.org/eclipselink/documentation/2.4/con cepts/nosql.htm Main Features • JPA API (Subset) • JPQL Query Language / Native Queries
  • 41. codecentric AG 43 EclipseLink NoSQL  Implements JPA API (subset)  JP-QL query are translated to native datastore queries  Oracle NoSQL, MongoDB
  • 42. codecentric AG 44 EclipseLink NoSQL MongoDB: Configuration <persistence version="2.0" …> <persistence-unit name="mongodb"> <class>hibernate.Order</class> <class>hibernate.Item</class> <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"/> <property name="eclipselink.nosql.property.mongo.host" value="127.0.0.1"/> <property name="eclipselink.nosql.property.mongo.db" value="odm_eclipselink"/> <property name="eclipselink.logging.level" value="FINE"/> </properties> </persistence-unit> </persistence>
  • 43. codecentric AG 45 EclipseLink NoSQL MongoDB : Object Mapping @Entity @NoSql(dataFormat=DataFormatType.MAPPED) public class Order { @GeneratedValue @Id @Field(name = "_id") private String id; private Date date; @Column(name = "custInfo") private String customerInfo; @ElementCollection private List<Item> items;
  • 44. codecentric AG 46 EclipseLink NoSQL MongoDB : Object Mapping @Embeddable @NoSql(dataFormat=DataFormatType.MAPPED) public class Item { private int quantity; private double price; @Column(name="desc") private String description; ...
  • 45. codecentric AG 47 EclipseLink NoSQL MongoDB : Queries // JPQL Order order = em.createQuery(  "SELECT o FROM Order o JOIN o.items i WHERE i.quantity = 2",  Order.class).getSingleResult(); // native Order order = (Order)em.createNativeQuery(  "db.ORDER.findOne({_id: "" + id + ""})",  Order.class).getSingleResult();
  • 46. codecentric AG 48 EclipseLink NoSQL MongoDB  Problems w/ nested native queries Uses relational API, TX required(?)
  • 47. codecentric AG 49 More JPA Providers for MongoDB  Hibernate OGM  Very early beta  No support for queries  Data Nucleus
  • 48. codecentric AG 50 Hibernate OGM: OgmEntityManager
  • 49. codecentric AG 51 Judge yourself … Spring Data MongoDB https://github.com/ttrelle/spring-data-examples Morphia https://github.com/ttrelle/morphia-mongodb-examples Jongo https://github.com/ttrelle/jongo-examples EclipseLink https://github.com/ttrelle/eclipselink-mongodb-examples
  • 50. codecentric AG 52 Summary ODM Annotations Queries Java Driver -- Nested BasicDBObject‘s Spring Data MongoDB Custom Interface w/ - derived queries - Native queries EclipseLink JPA + Custom JPQL: @Named(Native)Query + EntityManager Jongo Jackson JSON queries via collection wrapper Morphia Custom BasicDAO super class w/ 2 flavours of fluent API
  • 51. codecentric AG 53 Which one should I use? EclipseLink Spring Data MongoDB MongoDB Java Driver Morphia JPA JDBC MongoDB Jongo - Ready for production - Supported by MongoDB Inc. Mature - Ready for production - Active community - API mismatch The „better“ driver
  • 52. codecentric AG 54 MongoDB User Group Düsseldorf https://www.xing.com/net/mongodb-dus @MongoDUS MUG Düsseldorf
  • 53. codecentric AG 55 QUESTIONS? Tobias Trelle codecentric AG Merscheider Str. 1 42699 Solingen tel +49 (0) 212.233628.47 fax +49 (0) 212.233628.79 mail Tobias.Trelle@codecentric.de twitter @tobiastrelle www.codecentric.de blog.codecentric.de/en/author/tobias-trelle www.xing.com/net/mongodb-dus