SlideShare a Scribd company logo
1 of 78
MongoDB + Java
Everything you need to know
Agenda
• MongoDB + Java
• Driver
• ODM's
• JVM Languages
• Hadoop
Ola, I'm Norberto!
Norberto Leite
Technical Evangelist
Madrid, Spain
@nleite
norberto@mongodb.com
http://www.mongodb.com/norberto
A few announcements…
Announcements
Announcements
• Java 3.0.0-beta2 available for testing
– Generic MongoCollection
– New Codec infrastructure
– Asynchronous Support
– New core driver
• Better support for JVM languages
– https://github.com/mongodb/mongo-java-
driver/releases/tag/r3.0.0-beta2
• RX Streams – testing only!
– https://github.com/rozza/mongo-java-driver-
reactivestreams
http://www.humanandnatural.com/data/media/178/badan_jaran_desert_oasis_china.jpg
Let's go and test this!
http://www.tinypm.com/blog/wp-content/uploads/2015/01/hammer.jpg
Java Driver
Getting Started
• Review our documentation
– http://docs.mongodb.org/ecosystem/drivers/java/
Connecting
http://std3.ru/d3/09/1379154681-d309dacac47a71fb92480157f1d9a0ea.jpg
Connecting
public void connect() throws UnknownHostException{
String host = "mongodb://localhost:27017";
//connect to host
MongoClient mongoClient = new MongoClient(host);
…
}
Connecting
public void connect() throws UnknownHostException{
String host = "mongodb://localhost:27017";
//connect to host
MongoClient mongoClient = new MongoClient(host);
…
}
Client Instance
Host Machine
Connecting
public void connectServerAddress() throws UnknownHostException{
String host = "mongodb://localhost:27017";
//using ServerAddress
ServerAddress serverAddress = new ServerAddress(host);
//connect to host
MongoClient mongoClient = new MongoClient(serverAddress);
…
}
Connecting
public void connectServerAddress() throws UnknownHostException{
String host = "mongodb://localhost:27017";
//using ServerAddress
ServerAddress serverAddress = new ServerAddress(host);
//connect to host
MongoClient mongoClient = new MongoClient(serverAddress);
…
}
Server Address Instance
Connecting
public boolean connectReplicas() throws UnknownHostException{
//replica set members
String []hosts = {
"mongodb://localhost:30000",
"mongodb://localhost:30001",
"mongodb://localhost:30000",
};
//list of ServerAdress
List<ServerAddress> seeds = new ArrayList<ServerAddress>();
for (String h: hosts){
seeds.add(new ServerAddress(h));
}
//connect to host
MongoClient mongoClient = new MongoClient(seeds);
…
}
Connecting
public boolean connectReplicas() throws UnknownHostException{
//replica set members
String []hosts = {
"mongodb://localhost:30000",
"mongodb://localhost:30001",
"mongodb://localhost:30000",
};
//list of ServerAdress
List<ServerAddress> seeds = new ArrayList<ServerAddress>();
for (String h: hosts){
seeds.add(new ServerAddress(h));
}
//connect to host
MongoClient mongoClient = new MongoClient(seeds);
…
}
Seed List
Database & Collections
public void connectDatabase(final String dbname, final String collname){
//database instance
DB database = mongoClient.getDB(dbname);
//collection instance
DBCollection collection = database.getCollection(collname);
https://api.mongodb.org/java/current/com/mongodb/DB.html
https://api.mongodb.org/java/current/com/mongodb/DBCollection.html
Security
public void connectServerAddress() throws UnknownHostException{
String host = "localhost:27017";
ServerAddress serverAddress = new ServerAddress(host);
String dbname = "test";
String userName = "norberto";
char[] password = {'a', 'b', 'c'};
MongoCredential credential = MongoCredential
.createMongoCRCredential(userName, dbname, password);
MongoClient mongoClient = new MongoClient(serverAddress,
Arrays.asList(credential));
http://docs.mongodb.org/ecosystem/tutorial/getting-started-with-java-
driver/#authentication-optional
Writing
http://std3.ru/d3/09/1379154681-d309dacac47a71fb92480157f1d9a0ea.jpg
Inserting
public boolean insertObject(SimplePojo p){
//lets insert on database `test`
String dbname = "test";
//on collection `simple`
String collname = "simple";
DBCollection collection = mc.getDB(dbname).getCollection(collname);
DBObject document = new BasicDBObject();
document.put("name", p.getName());
document.put("age", p.getAge());
document.put("address", p.getAddress());
//db.simple.insert( { "name": XYZ, "age": 45, "address": "49 Rue de Rivoli, 75001
Paris"})
collection.insert(document);…
}
Inserting
public boolean insertObject(SimplePojo p){
//lets insert on database `test`
String dbname = "test";
//on collection `simple`
String collname = "simple";
DBCollection collection = mc.getDB(dbname).getCollection(collname);
DBObject document = new BasicDBObject();
document.put("name", p.getName());
document.put("age", p.getAge());
document.put("address", p.getAddress());
//db.simple.insert( { "name": XYZ, "age": 45, "address": "49 Rue de Rivoli, 75001 Paris"})
collection.insert(document);
…
}
Collection instance
BSON wrapper
Inserting
public boolean insertObject(SimplePojo p){
…
WriteResult result = collection.insert(document);
//log number of inserted documents
log.debug("Number of inserted results " + result.getN() );
…
}
https://api.mongodb.org/java/current/com/mongodb/DBObject.html
https://api.mongodb.org/java/current/com/mongodb/WriteResult.html
Update
public long savePojo(SimplePojo p) {
DBObject document = BasicDBObjectBuilder.start()
.add("name", p.getName())
.add("age", p.getAge())
.add("address", p.getAddress()).get();
//method replaces the existing database document by this new one
WriteResult res = this.collection.save(document);
//if it does not exist will create one (upsert)
return res.getN();
}
Update
public long savePojo(SimplePojo p) {
DBObject document = BasicDBObjectBuilder.start()
.add("name", p.getName())
.add("age", p.getAge())
.add("address", p.getAddress()).get();
//method replaces the existing database document by this new one
WriteResult res = this.collection.save(document);
//if it does not exist creates one (upsert)
return res.getN();
}
Save method
Update
public long updateAddress( SimplePojo p, Address a ){
//{ 'name': XYZ}
DBObject query = QueryBuilder.start("name").is(p.getName()).get();
DBObject address = BasicDBObjectBuilder.start()
.add("street", a.getStreet())
.add("city", a.getCity())
.add("number", a.getNumber())
.add("district", a.getDistrict()).get();
DBObject update = BasicDBObjectBuilder.start().add("name",
p.getName()).add("age", p.getAge()).add("address", address).get();
return this.collection.update(query, update).getN();
}
Update
public long updateAddress( SimplePojo p, Address a ){
//{ 'name': XYZ}
DBObject query = QueryBuilder.start("name").is(p.getName()).get();
DBObject address = BasicDBObjectBuilder.start()
.add("street", a.getStreet())
.add("city", a.getCity())
.add("number", a.getNumber())
.add("district", a.getDistrict()).get();
DBObject update = BasicDBObjectBuilder.start().add("name",
p.getName()).add("age", p.getAge()).add("address", address).get();
return this.collection.update(query, update).getN();
}
Query Object
Update Object
Update
public long updateSetAddress( SimplePojo p, Address a ){
//{ 'name': XYZ}
DBObject query = QueryBuilder.start("name").is(p.getName()).get();
DBObject address = BasicDBObjectBuilder.start()
.add("street", a.getStreet())
.add("city", a.getCity())
.add("number", a.getNumber())
.add("district", a.getDistrict()).get();
//db.simple.update( {"name": XYZ}, {"$set":{ "address": ...} } )
DBObject update = BasicDBObjectBuilder.start()
.append("$set", new BasicDBObject("address", address) ).get();
return this.collection.update(query, update).getN();
}
Update
public long updateSetAddress( SimplePojo p, Address a ){
//{ 'name': XYZ}
DBObject query = QueryBuilder.start("name").is(p.getName()).get();
DBObject address = BasicDBObjectBuilder.start()
.add("street", a.getStreet())
.add("city", a.getCity())
.add("number", a.getNumber())
.add("district", a.getDistrict()).get();
//db.simple.update( {"name": XYZ}, {"$set":{ "address": ...} } )
DBObject update = BasicDBObjectBuilder.start()
.append("$set", new BasicDBObject("address", address) ).get();
return this.collection.update(query, update).getN();
}
Using $set operator
http://docs.mongodb.org/manual/reference/operator/update/
Remove
public long removePojo( SimplePojo p){
//query object to match documents to be removed
DBObject query = BasicDBObjectBuilder.start().add("name", p.getName()).get();
return this.collection.remove(query).getN();
}
Remove
public long removePojo( SimplePojo p){
//query object to match documents to be removed
DBObject query = BasicDBObjectBuilder.start()
.add("name", p.getName()).get();
return this.collection.remove(query).getN();
}
Matching query
Remove All
public long removeAll( ){
//empty object removes all documents > db.simple.remove({})
return this.collection.remove(new BasicDBObject()).getN();
}
Empty document
http://docs.mongodb.org/manual/reference/method/db.collection.remove/
WriteConcern
http://std3.ru/d3/09/1379154681-d309dacac47a71fb92480157f1d9a0ea.jpghttp://www.theworldeffect.com/images/6a00e54fa8abf78833011570eedcf1970b-800wi.jpg
WriteConcern
//Default
WriteConcern w1 = WriteConcern.ACKNOWLEDGED;
WriteConcern w0 = WriteConcern.UNACKNOWLEDGED;
WriteConcern j1 = WriteConcern.JOURNALED;
WriteConcern wx = WriteConcern.REPLICA_ACKNOWLEDGED;
WriteConcern majority = WriteConcern.MAJORITY;
https://api.mongodb.org/java/current/com/mongodb/WriteConcern.html
WriteConcern.ACKNOWLEDGED
WriteConcern.UNACKNOWLEDGED
WriteConcern.JOURNALED
WriteConcern.REPLICA_ACKNOWLEDGED
WriteConcern
public boolean insertObjectWriteConcern(SimplePojo p){
…
WriteResult result = collection.insert(document,
WriteConcern.REPLICA_ACKNOWLEDGED);
//log number of inserted documents
log.debug("Number of inserted results " + result.getN() );
//log the last write concern used
log.info( "Last write concern used "+ result.getLastConcern() );…
}
WriteConcern
public boolean insertObjectWriteConcern(SimplePojo p){
…
WriteResult result = collection.insert(document,
WriteConcern.REPLICA_ACKNOWLEDGED);
//log number of inserted documents
log.debug("Number of inserted results " + result.getN() );
//log the last write concern used
log.info( "Last write concern used "+ result.getLastConcern() );
…
}
Confirm on Replicas
WriteConcern
public void setWriteConcernLevels(WriteConcern wc){
//connection level
this.mc.setWriteConcern(wc);
//database level
this.mc.getDB("test").setWriteConcern(wc);
//collection level
this.mc.getDB("test").getCollection("simple").setWriteConcern(wc);
//instruction level
this.mc.getDB("test").getCollection("simple").insert( new BasicDBObject() ,
wc);
}
Bulk Write
http://images.fineartamerica.com/images-medium-large/2-my-old-bucket-curt-simpson.jpg
Write Bulk
public boolean bulkInsert(List<SimplePojo> ps){
…
//initialize a bulk write operation
BulkWriteOperation bulkOp = coll.initializeUnorderedBulkOperation();
for (SimplePojo p : ps){
DBObject document = BasicDBObjectBuilder.start()
.add("name", p.getName())
.add("age", p.getAge())
.add("address", p.getAddress()).get();
bulkOp.insert(document);
}
//call the set of inserts
bulkOp.execute();
…
}
Inserting Bulk
public void writeSeveral( SimplePojo p, ComplexPojo c){
//initialize ordered bulk
BulkWriteOperation bulk = this.collection.initializeOrderedBulkOperation();
DBObject q1 = BasicDBObjectBuilder.start()
.add("name", p.getName()).get();
//remove the previous document
bulk.find(q1).removeOne();
//insert the new document
bulk.insert( c.encodeDBObject() );
BulkWriteResult result = bulk.execute();
//do something with the result
result.getClass();
}
Reading
http://std3.ru/d3/09/1379154681-d309dacac47a71fb92480157f1d9a0ea.jpghttp://1.bp.blogspot.com/_uYSlZ_2-VwI/SK0TrNUBVBI/AAAAAAAAASs/5334Tlv0IIY/s1600-h/lady_reading_book.jpg
Read
public SimplePojo get(){
//basic findOne operation
DBObject doc = this.collection.findOne();
SimplePojo pojo = new SimplePojo();
//casting to destination type
pojo.setAddress((String) doc.get("address"));
pojo.setAge( (int) doc.get("age") );
pojo.setAddress( (String) doc.get("address") );
return pojo;
}
Read
public List<SimplePojo> getSeveral(){
List<SimplePojo> pojos = new ArrayList<SimplePojo>();
//returns a cursor
DBCursor cursor = this.collection.find();
//iterates over the cursor
for (DBObject document : cursor){
//calls factory or transformation method
pojos.add( this.transform(document) );
}
return pojos;
}
Read
public List<SimplePojo> getSeveral(){
List<SimplePojo> pojos = new ArrayList<SimplePojo>();
//returns a cursor
DBCursor cursor = this.collection.find();
//iterates over the cursor
for (DBObject document : cursor){
//calls factory or transformation method
pojos.add( this.transform(document) );
}
return pojos;
}
Returns Cursor
Read
public List<SimplePojo> getAtAge(int age) {
List<SimplePojo> pojos = new ArrayList<SimplePojo>();
DBObject criteria = new BasicDBObject("age", age);
// matching operator { "age": age}
DBCursor cursor = this.collection.find(criteria);
// iterates over the cursor
for (DBObject document : cursor) {
// calls factory or transformation method
pojos.add(this.transform(document));
}
return pojos;
}
Matching operator
Read
public List<SimplePojo> getOlderThan( int minAge){
…
DBObject criteria = new BasicDBObject( "$gt",
new BasicDBObject("age", minAge));
// matching operator { "$gt": { "age": minAge} }
DBCursor cursor = this.collection.find(criteria);
…
}
Read
public List<SimplePojo> getOlderThan( int minAge){
…
DBObject criteria = new BasicDBObject( "$gt",
new BasicDBObject("age", minAge));
// matching operator { "$gt": { "age": minAge} }
DBCursor cursor = this.collection.find(criteria);
…
}
Range operator
http://docs.mongodb.org/manual/reference/operator/query/
Read & Filtering
public String getAddress(final String name) {
DBObject criteria = new BasicDBObject("name", name);
//we want the address field
DBObject fields = new BasicDBObject( "address", 1 );
//and exclude _id too
fields.put("_id", 0);
// db.simple.find( { "name": name}, {"_id:0", "address":1} )
DBObject document = this.collection.findOne(criteria, fields);
//we can check if this is a partial document
document.isPartialObject();
return (String) document.get("address");
}
Read & Filtering
public String getAddress(final String name) {
DBObject criteria = new BasicDBObject("name", name);
//we want the address field
DBObject fields = new BasicDBObject( "address", 1 );
//and exclude _id too
fields.put("_id", 0);
// db.simple.find( { "name": name}, {"_id:0", "address":1} )
DBObject document = this.collection.findOne(criteria, fields);
//we can check if this is a partial document
document.isPartialObject();
return (String) document.get("address");
}
Select fields
Read Preference
http://2.bp.blogspot.com/-CW3UtTpWoqg/UHhJ0gzjxcI/AAAAAAAAQz0/l_ozSnrwkvo/s1600/Grigori+Semenovich+Sedov+-+Choosing+the+bride+of+Czar+Alexis.jpg
Read Preference
//default
ReadPreference.primary();
ReadPreference.primaryPreferred();
ReadPreference.secondary();
ReadPreference.secondaryPreferred();
ReadPreference.nearest();
https://api.mongodb.org/java/current/com/mongodb/ReadPreference.html
Read Preference – Tag Aware
//read from specific tag
DBObject tag = new BasicDBObject( "datacenter", "Porto" );
ReadPreference readPref = ReadPreference.secondary(tag);
http://docs.mongodb.org/manual/tutorial/configure-replica-set-tag-sets/
Read Preference
public String getName( final int age ){
DBObject criteria = new BasicDBObject("age", age);
DBObject fields = new BasicDBObject( "name", 1 );
//set to read from nearest node
DBObject document = this.collection.findOne(criteria, fields,
ReadPreference.nearest() );
//return the element
return (String) document.get("name");
}
Read Preference
Aggregation
// create our pipeline operations, first with the $match
DBObject match = new BasicDBObject("$match", new
BasicDBObject("type", "airfare"));
// build the $projection operation
DBObject fields = new BasicDBObject("department", 1);
fields.put("amount", 1);
fields.put("_id", 0);
DBObject project = new BasicDBObject("$project", fields );
// Now the $group operation
DBObject groupFields = new BasicDBObject( "_id", "$department");
groupFields.put("average", new BasicDBObject( "$avg", "$amount"));
DBObject group = new BasicDBObject("$group", groupFields);
…
Aggregation
// Finally the $sort operation
DBObject sort = new BasicDBObject("$sort", new BasicDBObject("amount",
-1));
// run aggregation
List<DBObject> pipeline = Arrays.asList(match, project, group, sort);
AggregationOutput output = coll.aggregate(pipeline);
Java ODM's
Morphia
Morphia
Morphia
public class Employee {
// auto-generated, if not set (see ObjectId)
@Id ObjectId id;
// value types are automatically persisted
String firstName, lastName;
// only non-null values are stored
Long salary = null;
// by default fields are @Embedded
Address address;
…
}
Morphia
public class Employee {
…
//references can be saved without automatic loading
Key<Employee> manager;
//refs are stored**, and loaded automatically
@Reference List<Employee> underlings = new ArrayList<Employee>();
// stored in one binary field
@Serialized EncryptedReviews encryptedReviews;
//fields can be renamed
@Property("started") Date startDate;
@Property("left") Date endDate;
…
}
SpringData
Spring Data
http://projects.spring.io/spring-data-mongodb/
Jongo
Jongo
http://jongo.org/
Others
• DataNucleus JPA/JDO
• lib-mongomapper
• Kundera
• Hibernate OGM
JVM Languages
Scala
• http://docs.mongodb.org/ecosystem/drivers/scala/
• Cashbah
– Java Driver Wrapper
– Idiomatic Scala Interface for MongoDB
• Community
– Hammersmith
– Salat
– Reactive Mongo
– Lift Web Framework
– BlueEyes
– MSSD
Clojure
http://clojuremongodb.info/
Groovy
https://github.com/poiati/gmongo
Hadoop
MongoDB Hadoop Connector
• MongoDB and BSON
– Input and Output formats
• Computes splits to read data
• Support for
– Filtering data with MongoDB queries
– Authentication (and separate for configdb)
– Reading from shard Primary directly
– ReadPreferences and Replica Set tags (via MongoDB URI)
– Appending to existing collections (MapReduce, Pig, Spark)
For More Information
Resource Location
Case Studies mongodb.com/customers
Presentations mongodb.com/presentations
Free Online Training education.mongodb.com
Webinars and Events mongodb.com/events
Documentation docs.mongodb.org
MongoDB Downloads mongodb.com/download
Additional Info info@mongodb.com
http://cl.jroo.me/z3/v/D/C/e/a.baa-Too-many-bicycles-on-the-van.jpg
Questions?
@nleite
norberto@mongodb.com
http://www.mongodb.com/norberto
MongoDB + Java - Everything you need to know

More Related Content

What's hot

Morphia, Spring Data & Co.
Morphia, Spring Data & Co.Morphia, Spring Data & Co.
Morphia, Spring Data & Co.Tobias Trelle
 
Webinar: MongoDB Persistence with Java and Morphia
Webinar: MongoDB Persistence with Java and MorphiaWebinar: MongoDB Persistence with Java and Morphia
Webinar: MongoDB Persistence with Java and MorphiaMongoDB
 
MongoDB Performance Tuning
MongoDB Performance TuningMongoDB Performance Tuning
MongoDB Performance TuningPuneet Behl
 
Reactive Access to MongoDB from Java 8
Reactive Access to MongoDB from Java 8Reactive Access to MongoDB from Java 8
Reactive Access to MongoDB from Java 8Hermann Hueck
 
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
 
Spring Data, Jongo & Co.
Spring Data, Jongo & Co.Spring Data, Jongo & Co.
Spring Data, Jongo & Co.Tobias Trelle
 
Getting Started with MongoDB and NodeJS
Getting Started with MongoDB and NodeJSGetting Started with MongoDB and NodeJS
Getting Started with MongoDB and NodeJSMongoDB
 
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
 
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 World 2016: Deciphering .explain() Output
MongoDB World 2016: Deciphering .explain() OutputMongoDB World 2016: Deciphering .explain() Output
MongoDB World 2016: Deciphering .explain() OutputMongoDB
 
Map/Confused? A practical approach to Map/Reduce with MongoDB
Map/Confused? A practical approach to Map/Reduce with MongoDBMap/Confused? A practical approach to Map/Reduce with MongoDB
Map/Confused? A practical approach to Map/Reduce with MongoDBUwe Printz
 
Mythbusting: Understanding How We Measure the Performance of MongoDB
Mythbusting: Understanding How We Measure the Performance of MongoDBMythbusting: Understanding How We Measure the Performance of MongoDB
Mythbusting: Understanding How We Measure the Performance of MongoDBMongoDB
 
What do you mean, Backwards Compatibility?
What do you mean, Backwards Compatibility?What do you mean, Backwards Compatibility?
What do you mean, Backwards Compatibility?Trisha Gee
 
NoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love StoryNoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love StoryAlexandre Morgaut
 
DrupalCon Chicago Practical MongoDB and Drupal
DrupalCon Chicago Practical MongoDB and DrupalDrupalCon Chicago Practical MongoDB and Drupal
DrupalCon Chicago Practical MongoDB and DrupalDoug Green
 
Indexing and Query Optimizer (Mongo Austin)
Indexing and Query Optimizer (Mongo Austin)Indexing and Query Optimizer (Mongo Austin)
Indexing and Query Optimizer (Mongo Austin)MongoDB
 
Building Apps with MongoDB
Building Apps with MongoDBBuilding Apps with MongoDB
Building Apps with MongoDBNate Abele
 
MongoDB Performance Tuning
MongoDB Performance TuningMongoDB Performance Tuning
MongoDB Performance TuningMongoDB
 

What's hot (19)

Morphia, Spring Data & Co.
Morphia, Spring Data & Co.Morphia, Spring Data & Co.
Morphia, Spring Data & Co.
 
Webinar: MongoDB Persistence with Java and Morphia
Webinar: MongoDB Persistence with Java and MorphiaWebinar: MongoDB Persistence with Java and Morphia
Webinar: MongoDB Persistence with Java and Morphia
 
MongoDB Performance Tuning
MongoDB Performance TuningMongoDB Performance Tuning
MongoDB Performance Tuning
 
Reactive Access to MongoDB from Java 8
Reactive Access to MongoDB from Java 8Reactive Access to MongoDB from Java 8
Reactive Access to MongoDB from Java 8
 
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
 
Spring Data, Jongo & Co.
Spring Data, Jongo & Co.Spring Data, Jongo & Co.
Spring Data, Jongo & Co.
 
Getting Started with MongoDB and NodeJS
Getting Started with MongoDB and NodeJSGetting Started with MongoDB and NodeJS
Getting Started with MongoDB and NodeJS
 
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
 
MongoDB crud
MongoDB crudMongoDB crud
MongoDB crud
 
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 World 2016: Deciphering .explain() Output
MongoDB World 2016: Deciphering .explain() OutputMongoDB World 2016: Deciphering .explain() Output
MongoDB World 2016: Deciphering .explain() Output
 
Map/Confused? A practical approach to Map/Reduce with MongoDB
Map/Confused? A practical approach to Map/Reduce with MongoDBMap/Confused? A practical approach to Map/Reduce with MongoDB
Map/Confused? A practical approach to Map/Reduce with MongoDB
 
Mythbusting: Understanding How We Measure the Performance of MongoDB
Mythbusting: Understanding How We Measure the Performance of MongoDBMythbusting: Understanding How We Measure the Performance of MongoDB
Mythbusting: Understanding How We Measure the Performance of MongoDB
 
What do you mean, Backwards Compatibility?
What do you mean, Backwards Compatibility?What do you mean, Backwards Compatibility?
What do you mean, Backwards Compatibility?
 
NoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love StoryNoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love Story
 
DrupalCon Chicago Practical MongoDB and Drupal
DrupalCon Chicago Practical MongoDB and DrupalDrupalCon Chicago Practical MongoDB and Drupal
DrupalCon Chicago Practical MongoDB and Drupal
 
Indexing and Query Optimizer (Mongo Austin)
Indexing and Query Optimizer (Mongo Austin)Indexing and Query Optimizer (Mongo Austin)
Indexing and Query Optimizer (Mongo Austin)
 
Building Apps with MongoDB
Building Apps with MongoDBBuilding Apps with MongoDB
Building Apps with MongoDB
 
MongoDB Performance Tuning
MongoDB Performance TuningMongoDB Performance Tuning
MongoDB Performance Tuning
 

Viewers also liked

Building Spring Data with MongoDB
Building Spring Data with MongoDBBuilding Spring Data with MongoDB
Building Spring Data with MongoDBMongoDB
 
WebEngage demo at Unpluggd (Nov, 2011)
WebEngage demo at Unpluggd (Nov, 2011)WebEngage demo at Unpluggd (Nov, 2011)
WebEngage demo at Unpluggd (Nov, 2011)Avlesh Singh
 
The Spring Data MongoDB Project
The Spring Data MongoDB ProjectThe Spring Data MongoDB Project
The Spring Data MongoDB ProjectMongoDB
 
PHP client - Mongo db User Group Pune
PHP client - Mongo db User Group PunePHP client - Mongo db User Group Pune
PHP client - Mongo db User Group PuneNishant Shrivastava
 
Spring Data MongoDB 介紹
Spring Data MongoDB 介紹Spring Data MongoDB 介紹
Spring Data MongoDB 介紹Kuo-Chun Su
 
MongoDB training for java software engineers
MongoDB training for java software engineersMongoDB training for java software engineers
MongoDB training for java software engineersMoshe Kaplan
 
Build an AngularJS, Java, MongoDB Web App in an hour
Build an AngularJS, Java, MongoDB Web App in an hourBuild an AngularJS, Java, MongoDB Web App in an hour
Build an AngularJS, Java, MongoDB Web App in an hourTrisha Gee
 
Mongo DB on the JVM - Brendan McAdams
Mongo DB on the JVM - Brendan McAdamsMongo DB on the JVM - Brendan McAdams
Mongo DB on the JVM - Brendan McAdamsJAX London
 
Reactive Access to MongoDB from Scala
Reactive Access to MongoDB from ScalaReactive Access to MongoDB from Scala
Reactive Access to MongoDB from ScalaHermann Hueck
 
Migrating from RDBMS to MongoDB
Migrating from RDBMS to MongoDBMigrating from RDBMS to MongoDB
Migrating from RDBMS to MongoDBMongoDB
 
AngularJS performance & production tips
AngularJS performance & production tipsAngularJS performance & production tips
AngularJS performance & production tipsNir Kaufman
 
How to monitor MongoDB
How to monitor MongoDBHow to monitor MongoDB
How to monitor MongoDBServer Density
 
The Aggregation Framework
The Aggregation FrameworkThe Aggregation Framework
The Aggregation FrameworkMongoDB
 
ng-owasp: OWASP Top 10 for AngularJS Applications
ng-owasp: OWASP Top 10 for AngularJS Applicationsng-owasp: OWASP Top 10 for AngularJS Applications
ng-owasp: OWASP Top 10 for AngularJS ApplicationsKevin Hakanson
 
Tests & recette - Les fondamentaux
Tests & recette - Les fondamentauxTests & recette - Les fondamentaux
Tests & recette - Les fondamentauxCOMPETENSIS
 
Présentation Agile Testing
Présentation Agile TestingPrésentation Agile Testing
Présentation Agile Testingjubehr
 

Viewers also liked (18)

Building Spring Data with MongoDB
Building Spring Data with MongoDBBuilding Spring Data with MongoDB
Building Spring Data with MongoDB
 
WebEngage demo at Unpluggd (Nov, 2011)
WebEngage demo at Unpluggd (Nov, 2011)WebEngage demo at Unpluggd (Nov, 2011)
WebEngage demo at Unpluggd (Nov, 2011)
 
The Spring Data MongoDB Project
The Spring Data MongoDB ProjectThe Spring Data MongoDB Project
The Spring Data MongoDB Project
 
PHP client - Mongo db User Group Pune
PHP client - Mongo db User Group PunePHP client - Mongo db User Group Pune
PHP client - Mongo db User Group Pune
 
Spring Data MongoDB 介紹
Spring Data MongoDB 介紹Spring Data MongoDB 介紹
Spring Data MongoDB 介紹
 
MongoDB training for java software engineers
MongoDB training for java software engineersMongoDB training for java software engineers
MongoDB training for java software engineers
 
Build an AngularJS, Java, MongoDB Web App in an hour
Build an AngularJS, Java, MongoDB Web App in an hourBuild an AngularJS, Java, MongoDB Web App in an hour
Build an AngularJS, Java, MongoDB Web App in an hour
 
Mongo DB on the JVM - Brendan McAdams
Mongo DB on the JVM - Brendan McAdamsMongo DB on the JVM - Brendan McAdams
Mongo DB on the JVM - Brendan McAdams
 
Reactive Access to MongoDB from Scala
Reactive Access to MongoDB from ScalaReactive Access to MongoDB from Scala
Reactive Access to MongoDB from Scala
 
Mongo DB
Mongo DB Mongo DB
Mongo DB
 
Migrating from RDBMS to MongoDB
Migrating from RDBMS to MongoDBMigrating from RDBMS to MongoDB
Migrating from RDBMS to MongoDB
 
AngularJS performance & production tips
AngularJS performance & production tipsAngularJS performance & production tips
AngularJS performance & production tips
 
Génie Logiciel : les tests
Génie Logiciel : les testsGénie Logiciel : les tests
Génie Logiciel : les tests
 
How to monitor MongoDB
How to monitor MongoDBHow to monitor MongoDB
How to monitor MongoDB
 
The Aggregation Framework
The Aggregation FrameworkThe Aggregation Framework
The Aggregation Framework
 
ng-owasp: OWASP Top 10 for AngularJS Applications
ng-owasp: OWASP Top 10 for AngularJS Applicationsng-owasp: OWASP Top 10 for AngularJS Applications
ng-owasp: OWASP Top 10 for AngularJS Applications
 
Tests & recette - Les fondamentaux
Tests & recette - Les fondamentauxTests & recette - Les fondamentaux
Tests & recette - Les fondamentaux
 
Présentation Agile Testing
Présentation Agile TestingPrésentation Agile Testing
Présentation Agile Testing
 

Similar to MongoDB + Java - Everything you need to know

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
 
CouchDB on Android
CouchDB on AndroidCouchDB on Android
CouchDB on AndroidSven Haiges
 
How to Write Node.js Module
How to Write Node.js ModuleHow to Write Node.js Module
How to Write Node.js ModuleFred Chien
 
Conceptos básicos. Seminario web 2: Su primera aplicación MongoDB
 Conceptos básicos. Seminario web 2: Su primera aplicación MongoDB Conceptos básicos. Seminario web 2: Su primera aplicación MongoDB
Conceptos básicos. Seminario web 2: Su primera aplicación MongoDBMongoDB
 
Micro-ORM Introduction - Don't overcomplicate
Micro-ORM Introduction - Don't overcomplicateMicro-ORM Introduction - Don't overcomplicate
Micro-ORM Introduction - Don't overcomplicateKiev ALT.NET
 
Utilizing Powerful Extensions for Analytics and Operations
Utilizing Powerful Extensions for Analytics and OperationsUtilizing Powerful Extensions for Analytics and Operations
Utilizing Powerful Extensions for Analytics and OperationsNeo4j
 
Neo4j GraphTour: Utilizing Powerful Extensions for Analytics and Operations
Neo4j GraphTour: Utilizing Powerful Extensions for Analytics and OperationsNeo4j GraphTour: Utilizing Powerful Extensions for Analytics and Operations
Neo4j GraphTour: Utilizing Powerful Extensions for Analytics and OperationsMark Needham
 
[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVCAlive Kuo
 
GraphTour - Utilizing Powerful Extensions for Analytics & Operations
GraphTour - Utilizing Powerful Extensions for Analytics & OperationsGraphTour - Utilizing Powerful Extensions for Analytics & Operations
GraphTour - Utilizing Powerful Extensions for Analytics & OperationsNeo4j
 
Projeto-web-services-Spring-Boot-JPA.pdf
Projeto-web-services-Spring-Boot-JPA.pdfProjeto-web-services-Spring-Boot-JPA.pdf
Projeto-web-services-Spring-Boot-JPA.pdfAdrianoSantos888423
 
Full stack development with node and NoSQL - All Things Open - October 2017
Full stack development with node and NoSQL - All Things Open - October 2017Full stack development with node and NoSQL - All Things Open - October 2017
Full stack development with node and NoSQL - All Things Open - October 2017Matthew Groves
 
Full Stack Development with Node.js and NoSQL
Full Stack Development with Node.js and NoSQLFull Stack Development with Node.js and NoSQL
Full Stack Development with Node.js and NoSQLAll Things Open
 
This upload requires better support for ODP format
This upload requires better support for ODP formatThis upload requires better support for ODP format
This upload requires better support for ODP formatForest Mars
 
CouchDB Mobile - From Couch to 5K in 1 Hour
CouchDB Mobile - From Couch to 5K in 1 HourCouchDB Mobile - From Couch to 5K in 1 Hour
CouchDB Mobile - From Couch to 5K in 1 HourPeter Friese
 
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
 
Webinar: What's new in the .NET Driver
Webinar: What's new in the .NET DriverWebinar: What's new in the .NET Driver
Webinar: What's new in the .NET DriverMongoDB
 
Utilizing Powerful Extensions for Analytics and Operations
Utilizing Powerful Extensions for Analytics and OperationsUtilizing Powerful Extensions for Analytics and Operations
Utilizing Powerful Extensions for Analytics and OperationsNeo4j
 
My way to clean android - Android day salamanca edition
My way to clean android - Android day salamanca editionMy way to clean android - Android day salamanca edition
My way to clean android - Android day salamanca editionChristian Panadero
 
Webinaire 2 de la série « Retour aux fondamentaux » : Votre première applicat...
Webinaire 2 de la série « Retour aux fondamentaux » : Votre première applicat...Webinaire 2 de la série « Retour aux fondamentaux » : Votre première applicat...
Webinaire 2 de la série « Retour aux fondamentaux » : Votre première applicat...MongoDB
 

Similar to MongoDB + Java - Everything you need to know (20)

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
 
CouchDB on Android
CouchDB on AndroidCouchDB on Android
CouchDB on Android
 
How to Write Node.js Module
How to Write Node.js ModuleHow to Write Node.js Module
How to Write Node.js Module
 
Conceptos básicos. Seminario web 2: Su primera aplicación MongoDB
 Conceptos básicos. Seminario web 2: Su primera aplicación MongoDB Conceptos básicos. Seminario web 2: Su primera aplicación MongoDB
Conceptos básicos. Seminario web 2: Su primera aplicación MongoDB
 
Micro-ORM Introduction - Don't overcomplicate
Micro-ORM Introduction - Don't overcomplicateMicro-ORM Introduction - Don't overcomplicate
Micro-ORM Introduction - Don't overcomplicate
 
Utilizing Powerful Extensions for Analytics and Operations
Utilizing Powerful Extensions for Analytics and OperationsUtilizing Powerful Extensions for Analytics and Operations
Utilizing Powerful Extensions for Analytics and Operations
 
Neo4j GraphTour: Utilizing Powerful Extensions for Analytics and Operations
Neo4j GraphTour: Utilizing Powerful Extensions for Analytics and OperationsNeo4j GraphTour: Utilizing Powerful Extensions for Analytics and Operations
Neo4j GraphTour: Utilizing Powerful Extensions for Analytics and Operations
 
[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC
 
Play!ng with scala
Play!ng with scalaPlay!ng with scala
Play!ng with scala
 
GraphTour - Utilizing Powerful Extensions for Analytics & Operations
GraphTour - Utilizing Powerful Extensions for Analytics & OperationsGraphTour - Utilizing Powerful Extensions for Analytics & Operations
GraphTour - Utilizing Powerful Extensions for Analytics & Operations
 
Projeto-web-services-Spring-Boot-JPA.pdf
Projeto-web-services-Spring-Boot-JPA.pdfProjeto-web-services-Spring-Boot-JPA.pdf
Projeto-web-services-Spring-Boot-JPA.pdf
 
Full stack development with node and NoSQL - All Things Open - October 2017
Full stack development with node and NoSQL - All Things Open - October 2017Full stack development with node and NoSQL - All Things Open - October 2017
Full stack development with node and NoSQL - All Things Open - October 2017
 
Full Stack Development with Node.js and NoSQL
Full Stack Development with Node.js and NoSQLFull Stack Development with Node.js and NoSQL
Full Stack Development with Node.js and NoSQL
 
This upload requires better support for ODP format
This upload requires better support for ODP formatThis upload requires better support for ODP format
This upload requires better support for ODP format
 
CouchDB Mobile - From Couch to 5K in 1 Hour
CouchDB Mobile - From Couch to 5K in 1 HourCouchDB Mobile - From Couch to 5K in 1 Hour
CouchDB Mobile - From Couch to 5K in 1 Hour
 
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
 
Webinar: What's new in the .NET Driver
Webinar: What's new in the .NET DriverWebinar: What's new in the .NET Driver
Webinar: What's new in the .NET Driver
 
Utilizing Powerful Extensions for Analytics and Operations
Utilizing Powerful Extensions for Analytics and OperationsUtilizing Powerful Extensions for Analytics and Operations
Utilizing Powerful Extensions for Analytics and Operations
 
My way to clean android - Android day salamanca edition
My way to clean android - Android day salamanca editionMy way to clean android - Android day salamanca edition
My way to clean android - Android day salamanca edition
 
Webinaire 2 de la série « Retour aux fondamentaux » : Votre première applicat...
Webinaire 2 de la série « Retour aux fondamentaux » : Votre première applicat...Webinaire 2 de la série « Retour aux fondamentaux » : Votre première applicat...
Webinaire 2 de la série « Retour aux fondamentaux » : Votre première applicat...
 

More from Norberto Leite

Data Modelling for MongoDB - MongoDB.local Tel Aviv
Data Modelling for MongoDB - MongoDB.local Tel AvivData Modelling for MongoDB - MongoDB.local Tel Aviv
Data Modelling for MongoDB - MongoDB.local Tel AvivNorberto Leite
 
MongoDB Certification Study Group - May 2016
MongoDB Certification Study Group - May 2016MongoDB Certification Study Group - May 2016
MongoDB Certification Study Group - May 2016Norberto Leite
 
Geospatial and MongoDB
Geospatial and MongoDBGeospatial and MongoDB
Geospatial and MongoDBNorberto Leite
 
MongoDB WiredTiger Internals
MongoDB WiredTiger InternalsMongoDB WiredTiger Internals
MongoDB WiredTiger InternalsNorberto Leite
 
MongoDB 3.2 Feature Preview
MongoDB 3.2 Feature PreviewMongoDB 3.2 Feature Preview
MongoDB 3.2 Feature PreviewNorberto Leite
 
MongoDB: Agile Combustion Engine
MongoDB: Agile Combustion EngineMongoDB: Agile Combustion Engine
MongoDB: Agile Combustion EngineNorberto Leite
 
MongoDB Capacity Planning
MongoDB Capacity PlanningMongoDB Capacity Planning
MongoDB Capacity PlanningNorberto Leite
 
Strongly Typed Languages and Flexible Schemas
Strongly Typed Languages and Flexible SchemasStrongly Typed Languages and Flexible Schemas
Strongly Typed Languages and Flexible SchemasNorberto Leite
 
Effectively Deploying MongoDB on AEM
Effectively Deploying MongoDB on AEMEffectively Deploying MongoDB on AEM
Effectively Deploying MongoDB on AEMNorberto Leite
 
Advanced applications with MongoDB
Advanced applications with MongoDBAdvanced applications with MongoDB
Advanced applications with MongoDBNorberto Leite
 

More from Norberto Leite (20)

Data Modelling for MongoDB - MongoDB.local Tel Aviv
Data Modelling for MongoDB - MongoDB.local Tel AvivData Modelling for MongoDB - MongoDB.local Tel Aviv
Data Modelling for MongoDB - MongoDB.local Tel Aviv
 
Avoid Query Pitfalls
Avoid Query PitfallsAvoid Query Pitfalls
Avoid Query Pitfalls
 
MongoDB and Spark
MongoDB and SparkMongoDB and Spark
MongoDB and Spark
 
Mongo db 3.4 Overview
Mongo db 3.4 OverviewMongo db 3.4 Overview
Mongo db 3.4 Overview
 
MongoDB Certification Study Group - May 2016
MongoDB Certification Study Group - May 2016MongoDB Certification Study Group - May 2016
MongoDB Certification Study Group - May 2016
 
Geospatial and MongoDB
Geospatial and MongoDBGeospatial and MongoDB
Geospatial and MongoDB
 
MongodB Internals
MongodB InternalsMongodB Internals
MongodB Internals
 
MongoDB WiredTiger Internals
MongoDB WiredTiger InternalsMongoDB WiredTiger Internals
MongoDB WiredTiger Internals
 
MongoDB 3.2 Feature Preview
MongoDB 3.2 Feature PreviewMongoDB 3.2 Feature Preview
MongoDB 3.2 Feature Preview
 
Mongodb Spring
Mongodb SpringMongodb Spring
Mongodb Spring
 
MongoDB on Azure
MongoDB on AzureMongoDB on Azure
MongoDB on Azure
 
MongoDB: Agile Combustion Engine
MongoDB: Agile Combustion EngineMongoDB: Agile Combustion Engine
MongoDB: Agile Combustion Engine
 
MongoDB Capacity Planning
MongoDB Capacity PlanningMongoDB Capacity Planning
MongoDB Capacity Planning
 
Spark and MongoDB
Spark and MongoDBSpark and MongoDB
Spark and MongoDB
 
Analyse Yourself
Analyse YourselfAnalyse Yourself
Analyse Yourself
 
Python and MongoDB
Python and MongoDB Python and MongoDB
Python and MongoDB
 
Strongly Typed Languages and Flexible Schemas
Strongly Typed Languages and Flexible SchemasStrongly Typed Languages and Flexible Schemas
Strongly Typed Languages and Flexible Schemas
 
Effectively Deploying MongoDB on AEM
Effectively Deploying MongoDB on AEMEffectively Deploying MongoDB on AEM
Effectively Deploying MongoDB on AEM
 
Advanced applications with MongoDB
Advanced applications with MongoDBAdvanced applications with MongoDB
Advanced applications with MongoDB
 
MongoDB and Node.js
MongoDB and Node.jsMongoDB and Node.js
MongoDB and Node.js
 

Recently uploaded

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
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
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
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
 
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
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
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
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
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
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 

Recently uploaded (20)

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
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
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
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
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
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...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 

MongoDB + Java - Everything you need to know

  • 1.
  • 2. MongoDB + Java Everything you need to know
  • 3. Agenda • MongoDB + Java • Driver • ODM's • JVM Languages • Hadoop
  • 4. Ola, I'm Norberto! Norberto Leite Technical Evangelist Madrid, Spain @nleite norberto@mongodb.com http://www.mongodb.com/norberto
  • 7. Announcements • Java 3.0.0-beta2 available for testing – Generic MongoCollection – New Codec infrastructure – Asynchronous Support – New core driver • Better support for JVM languages – https://github.com/mongodb/mongo-java- driver/releases/tag/r3.0.0-beta2 • RX Streams – testing only! – https://github.com/rozza/mongo-java-driver- reactivestreams
  • 8. http://www.humanandnatural.com/data/media/178/badan_jaran_desert_oasis_china.jpg Let's go and test this! http://www.tinypm.com/blog/wp-content/uploads/2015/01/hammer.jpg
  • 10. Getting Started • Review our documentation – http://docs.mongodb.org/ecosystem/drivers/java/
  • 12. Connecting public void connect() throws UnknownHostException{ String host = "mongodb://localhost:27017"; //connect to host MongoClient mongoClient = new MongoClient(host); … }
  • 13. Connecting public void connect() throws UnknownHostException{ String host = "mongodb://localhost:27017"; //connect to host MongoClient mongoClient = new MongoClient(host); … } Client Instance Host Machine
  • 14. Connecting public void connectServerAddress() throws UnknownHostException{ String host = "mongodb://localhost:27017"; //using ServerAddress ServerAddress serverAddress = new ServerAddress(host); //connect to host MongoClient mongoClient = new MongoClient(serverAddress); … }
  • 15. Connecting public void connectServerAddress() throws UnknownHostException{ String host = "mongodb://localhost:27017"; //using ServerAddress ServerAddress serverAddress = new ServerAddress(host); //connect to host MongoClient mongoClient = new MongoClient(serverAddress); … } Server Address Instance
  • 16. Connecting public boolean connectReplicas() throws UnknownHostException{ //replica set members String []hosts = { "mongodb://localhost:30000", "mongodb://localhost:30001", "mongodb://localhost:30000", }; //list of ServerAdress List<ServerAddress> seeds = new ArrayList<ServerAddress>(); for (String h: hosts){ seeds.add(new ServerAddress(h)); } //connect to host MongoClient mongoClient = new MongoClient(seeds); … }
  • 17. Connecting public boolean connectReplicas() throws UnknownHostException{ //replica set members String []hosts = { "mongodb://localhost:30000", "mongodb://localhost:30001", "mongodb://localhost:30000", }; //list of ServerAdress List<ServerAddress> seeds = new ArrayList<ServerAddress>(); for (String h: hosts){ seeds.add(new ServerAddress(h)); } //connect to host MongoClient mongoClient = new MongoClient(seeds); … } Seed List
  • 18. Database & Collections public void connectDatabase(final String dbname, final String collname){ //database instance DB database = mongoClient.getDB(dbname); //collection instance DBCollection collection = database.getCollection(collname); https://api.mongodb.org/java/current/com/mongodb/DB.html https://api.mongodb.org/java/current/com/mongodb/DBCollection.html
  • 19. Security public void connectServerAddress() throws UnknownHostException{ String host = "localhost:27017"; ServerAddress serverAddress = new ServerAddress(host); String dbname = "test"; String userName = "norberto"; char[] password = {'a', 'b', 'c'}; MongoCredential credential = MongoCredential .createMongoCRCredential(userName, dbname, password); MongoClient mongoClient = new MongoClient(serverAddress, Arrays.asList(credential)); http://docs.mongodb.org/ecosystem/tutorial/getting-started-with-java- driver/#authentication-optional
  • 21. Inserting public boolean insertObject(SimplePojo p){ //lets insert on database `test` String dbname = "test"; //on collection `simple` String collname = "simple"; DBCollection collection = mc.getDB(dbname).getCollection(collname); DBObject document = new BasicDBObject(); document.put("name", p.getName()); document.put("age", p.getAge()); document.put("address", p.getAddress()); //db.simple.insert( { "name": XYZ, "age": 45, "address": "49 Rue de Rivoli, 75001 Paris"}) collection.insert(document);… }
  • 22. Inserting public boolean insertObject(SimplePojo p){ //lets insert on database `test` String dbname = "test"; //on collection `simple` String collname = "simple"; DBCollection collection = mc.getDB(dbname).getCollection(collname); DBObject document = new BasicDBObject(); document.put("name", p.getName()); document.put("age", p.getAge()); document.put("address", p.getAddress()); //db.simple.insert( { "name": XYZ, "age": 45, "address": "49 Rue de Rivoli, 75001 Paris"}) collection.insert(document); … } Collection instance BSON wrapper
  • 23. Inserting public boolean insertObject(SimplePojo p){ … WriteResult result = collection.insert(document); //log number of inserted documents log.debug("Number of inserted results " + result.getN() ); … } https://api.mongodb.org/java/current/com/mongodb/DBObject.html https://api.mongodb.org/java/current/com/mongodb/WriteResult.html
  • 24. Update public long savePojo(SimplePojo p) { DBObject document = BasicDBObjectBuilder.start() .add("name", p.getName()) .add("age", p.getAge()) .add("address", p.getAddress()).get(); //method replaces the existing database document by this new one WriteResult res = this.collection.save(document); //if it does not exist will create one (upsert) return res.getN(); }
  • 25. Update public long savePojo(SimplePojo p) { DBObject document = BasicDBObjectBuilder.start() .add("name", p.getName()) .add("age", p.getAge()) .add("address", p.getAddress()).get(); //method replaces the existing database document by this new one WriteResult res = this.collection.save(document); //if it does not exist creates one (upsert) return res.getN(); } Save method
  • 26. Update public long updateAddress( SimplePojo p, Address a ){ //{ 'name': XYZ} DBObject query = QueryBuilder.start("name").is(p.getName()).get(); DBObject address = BasicDBObjectBuilder.start() .add("street", a.getStreet()) .add("city", a.getCity()) .add("number", a.getNumber()) .add("district", a.getDistrict()).get(); DBObject update = BasicDBObjectBuilder.start().add("name", p.getName()).add("age", p.getAge()).add("address", address).get(); return this.collection.update(query, update).getN(); }
  • 27. Update public long updateAddress( SimplePojo p, Address a ){ //{ 'name': XYZ} DBObject query = QueryBuilder.start("name").is(p.getName()).get(); DBObject address = BasicDBObjectBuilder.start() .add("street", a.getStreet()) .add("city", a.getCity()) .add("number", a.getNumber()) .add("district", a.getDistrict()).get(); DBObject update = BasicDBObjectBuilder.start().add("name", p.getName()).add("age", p.getAge()).add("address", address).get(); return this.collection.update(query, update).getN(); } Query Object Update Object
  • 28. Update public long updateSetAddress( SimplePojo p, Address a ){ //{ 'name': XYZ} DBObject query = QueryBuilder.start("name").is(p.getName()).get(); DBObject address = BasicDBObjectBuilder.start() .add("street", a.getStreet()) .add("city", a.getCity()) .add("number", a.getNumber()) .add("district", a.getDistrict()).get(); //db.simple.update( {"name": XYZ}, {"$set":{ "address": ...} } ) DBObject update = BasicDBObjectBuilder.start() .append("$set", new BasicDBObject("address", address) ).get(); return this.collection.update(query, update).getN(); }
  • 29. Update public long updateSetAddress( SimplePojo p, Address a ){ //{ 'name': XYZ} DBObject query = QueryBuilder.start("name").is(p.getName()).get(); DBObject address = BasicDBObjectBuilder.start() .add("street", a.getStreet()) .add("city", a.getCity()) .add("number", a.getNumber()) .add("district", a.getDistrict()).get(); //db.simple.update( {"name": XYZ}, {"$set":{ "address": ...} } ) DBObject update = BasicDBObjectBuilder.start() .append("$set", new BasicDBObject("address", address) ).get(); return this.collection.update(query, update).getN(); } Using $set operator http://docs.mongodb.org/manual/reference/operator/update/
  • 30. Remove public long removePojo( SimplePojo p){ //query object to match documents to be removed DBObject query = BasicDBObjectBuilder.start().add("name", p.getName()).get(); return this.collection.remove(query).getN(); }
  • 31. Remove public long removePojo( SimplePojo p){ //query object to match documents to be removed DBObject query = BasicDBObjectBuilder.start() .add("name", p.getName()).get(); return this.collection.remove(query).getN(); } Matching query
  • 32. Remove All public long removeAll( ){ //empty object removes all documents > db.simple.remove({}) return this.collection.remove(new BasicDBObject()).getN(); } Empty document http://docs.mongodb.org/manual/reference/method/db.collection.remove/
  • 34. WriteConcern //Default WriteConcern w1 = WriteConcern.ACKNOWLEDGED; WriteConcern w0 = WriteConcern.UNACKNOWLEDGED; WriteConcern j1 = WriteConcern.JOURNALED; WriteConcern wx = WriteConcern.REPLICA_ACKNOWLEDGED; WriteConcern majority = WriteConcern.MAJORITY; https://api.mongodb.org/java/current/com/mongodb/WriteConcern.html
  • 39. WriteConcern public boolean insertObjectWriteConcern(SimplePojo p){ … WriteResult result = collection.insert(document, WriteConcern.REPLICA_ACKNOWLEDGED); //log number of inserted documents log.debug("Number of inserted results " + result.getN() ); //log the last write concern used log.info( "Last write concern used "+ result.getLastConcern() );… }
  • 40. WriteConcern public boolean insertObjectWriteConcern(SimplePojo p){ … WriteResult result = collection.insert(document, WriteConcern.REPLICA_ACKNOWLEDGED); //log number of inserted documents log.debug("Number of inserted results " + result.getN() ); //log the last write concern used log.info( "Last write concern used "+ result.getLastConcern() ); … } Confirm on Replicas
  • 41. WriteConcern public void setWriteConcernLevels(WriteConcern wc){ //connection level this.mc.setWriteConcern(wc); //database level this.mc.getDB("test").setWriteConcern(wc); //collection level this.mc.getDB("test").getCollection("simple").setWriteConcern(wc); //instruction level this.mc.getDB("test").getCollection("simple").insert( new BasicDBObject() , wc); }
  • 43. Write Bulk public boolean bulkInsert(List<SimplePojo> ps){ … //initialize a bulk write operation BulkWriteOperation bulkOp = coll.initializeUnorderedBulkOperation(); for (SimplePojo p : ps){ DBObject document = BasicDBObjectBuilder.start() .add("name", p.getName()) .add("age", p.getAge()) .add("address", p.getAddress()).get(); bulkOp.insert(document); } //call the set of inserts bulkOp.execute(); … }
  • 44. Inserting Bulk public void writeSeveral( SimplePojo p, ComplexPojo c){ //initialize ordered bulk BulkWriteOperation bulk = this.collection.initializeOrderedBulkOperation(); DBObject q1 = BasicDBObjectBuilder.start() .add("name", p.getName()).get(); //remove the previous document bulk.find(q1).removeOne(); //insert the new document bulk.insert( c.encodeDBObject() ); BulkWriteResult result = bulk.execute(); //do something with the result result.getClass(); }
  • 46. Read public SimplePojo get(){ //basic findOne operation DBObject doc = this.collection.findOne(); SimplePojo pojo = new SimplePojo(); //casting to destination type pojo.setAddress((String) doc.get("address")); pojo.setAge( (int) doc.get("age") ); pojo.setAddress( (String) doc.get("address") ); return pojo; }
  • 47. Read public List<SimplePojo> getSeveral(){ List<SimplePojo> pojos = new ArrayList<SimplePojo>(); //returns a cursor DBCursor cursor = this.collection.find(); //iterates over the cursor for (DBObject document : cursor){ //calls factory or transformation method pojos.add( this.transform(document) ); } return pojos; }
  • 48. Read public List<SimplePojo> getSeveral(){ List<SimplePojo> pojos = new ArrayList<SimplePojo>(); //returns a cursor DBCursor cursor = this.collection.find(); //iterates over the cursor for (DBObject document : cursor){ //calls factory or transformation method pojos.add( this.transform(document) ); } return pojos; } Returns Cursor
  • 49. Read public List<SimplePojo> getAtAge(int age) { List<SimplePojo> pojos = new ArrayList<SimplePojo>(); DBObject criteria = new BasicDBObject("age", age); // matching operator { "age": age} DBCursor cursor = this.collection.find(criteria); // iterates over the cursor for (DBObject document : cursor) { // calls factory or transformation method pojos.add(this.transform(document)); } return pojos; } Matching operator
  • 50. Read public List<SimplePojo> getOlderThan( int minAge){ … DBObject criteria = new BasicDBObject( "$gt", new BasicDBObject("age", minAge)); // matching operator { "$gt": { "age": minAge} } DBCursor cursor = this.collection.find(criteria); … }
  • 51. Read public List<SimplePojo> getOlderThan( int minAge){ … DBObject criteria = new BasicDBObject( "$gt", new BasicDBObject("age", minAge)); // matching operator { "$gt": { "age": minAge} } DBCursor cursor = this.collection.find(criteria); … } Range operator http://docs.mongodb.org/manual/reference/operator/query/
  • 52. Read & Filtering public String getAddress(final String name) { DBObject criteria = new BasicDBObject("name", name); //we want the address field DBObject fields = new BasicDBObject( "address", 1 ); //and exclude _id too fields.put("_id", 0); // db.simple.find( { "name": name}, {"_id:0", "address":1} ) DBObject document = this.collection.findOne(criteria, fields); //we can check if this is a partial document document.isPartialObject(); return (String) document.get("address"); }
  • 53. Read & Filtering public String getAddress(final String name) { DBObject criteria = new BasicDBObject("name", name); //we want the address field DBObject fields = new BasicDBObject( "address", 1 ); //and exclude _id too fields.put("_id", 0); // db.simple.find( { "name": name}, {"_id:0", "address":1} ) DBObject document = this.collection.findOne(criteria, fields); //we can check if this is a partial document document.isPartialObject(); return (String) document.get("address"); } Select fields
  • 56. Read Preference – Tag Aware //read from specific tag DBObject tag = new BasicDBObject( "datacenter", "Porto" ); ReadPreference readPref = ReadPreference.secondary(tag); http://docs.mongodb.org/manual/tutorial/configure-replica-set-tag-sets/
  • 57. Read Preference public String getName( final int age ){ DBObject criteria = new BasicDBObject("age", age); DBObject fields = new BasicDBObject( "name", 1 ); //set to read from nearest node DBObject document = this.collection.findOne(criteria, fields, ReadPreference.nearest() ); //return the element return (String) document.get("name"); } Read Preference
  • 58. Aggregation // create our pipeline operations, first with the $match DBObject match = new BasicDBObject("$match", new BasicDBObject("type", "airfare")); // build the $projection operation DBObject fields = new BasicDBObject("department", 1); fields.put("amount", 1); fields.put("_id", 0); DBObject project = new BasicDBObject("$project", fields ); // Now the $group operation DBObject groupFields = new BasicDBObject( "_id", "$department"); groupFields.put("average", new BasicDBObject( "$avg", "$amount")); DBObject group = new BasicDBObject("$group", groupFields); …
  • 59. Aggregation // Finally the $sort operation DBObject sort = new BasicDBObject("$sort", new BasicDBObject("amount", -1)); // run aggregation List<DBObject> pipeline = Arrays.asList(match, project, group, sort); AggregationOutput output = coll.aggregate(pipeline);
  • 63. Morphia public class Employee { // auto-generated, if not set (see ObjectId) @Id ObjectId id; // value types are automatically persisted String firstName, lastName; // only non-null values are stored Long salary = null; // by default fields are @Embedded Address address; … }
  • 64. Morphia public class Employee { … //references can be saved without automatic loading Key<Employee> manager; //refs are stored**, and loaded automatically @Reference List<Employee> underlings = new ArrayList<Employee>(); // stored in one binary field @Serialized EncryptedReviews encryptedReviews; //fields can be renamed @Property("started") Date startDate; @Property("left") Date endDate; … }
  • 67. Jongo
  • 69. Others • DataNucleus JPA/JDO • lib-mongomapper • Kundera • Hibernate OGM
  • 71. Scala • http://docs.mongodb.org/ecosystem/drivers/scala/ • Cashbah – Java Driver Wrapper – Idiomatic Scala Interface for MongoDB • Community – Hammersmith – Salat – Reactive Mongo – Lift Web Framework – BlueEyes – MSSD
  • 75. MongoDB Hadoop Connector • MongoDB and BSON – Input and Output formats • Computes splits to read data • Support for – Filtering data with MongoDB queries – Authentication (and separate for configdb) – Reading from shard Primary directly – ReadPreferences and Replica Set tags (via MongoDB URI) – Appending to existing collections (MapReduce, Pig, Spark)
  • 76. For More Information Resource Location Case Studies mongodb.com/customers Presentations mongodb.com/presentations Free Online Training education.mongodb.com Webinars and Events mongodb.com/events Documentation docs.mongodb.org MongoDB Downloads mongodb.com/download Additional Info info@mongodb.com

Editor's Notes

  1. Replacing objects highly inefficient and should be avoided.