SlideShare a Scribd company logo
MongoDB + Spring
MongoDB + Spring
Norberto Leite
@nleite
norberto@mongodb.com
http://www.mongodb.com/norberto
Two leafs of the same tree
3
Agenda
• MongoDB Introduction
– Just in case you've been distracted
• Spring Framework Overview
• Spring + MongoDB
– Spring Data
– Spring Boot
– Spring Batch
4
Ola, I'm Norberto!
Norberto Leite
Technical Evangelist
Madrid, Spain
@nleite
norberto@mongodb.com
http://www.mongodb.com/norberto
MongoDB
6
MongoDB
GENERAL PURPOSE DOCUMENT DATABASE OPEN-SOURCE
7
MONGODB FEATURES
JSON Document Model
with Dynamic Schemas
Auto-Sharding for
Horizontal Scalability
Text Search
Aggregation Framework
and MapReduce
Full, Flexible Index Support
and Rich Queries
Built-In Replication
for High Availability
Advanced Security
Large Media Storage
with GridFS
8
THE LARGEST ECOSYSTEM
9,000,000+
MongoDB Downloads
250,000+
Online Education Registrants
35,000+
MongoDB User Group Members
35,000+
MongoDB Management Service (MMS) Users
750+
Technology and Services Partners
2,000+
Customers Across All Industries
Document Data Model
Relational MongoDB
{
first_name: ‘Paul’,
surname: ‘Miller’,
city: ‘London’,
location:
[45.123,47.232],
cars: [
{ model: ‘Bentley’,
year: 1973,
value: 100000, … },
{ model: ‘Rolls Royce’,
year: 1965,
value: 330000, … }
]
}
10
Documents are Rich Data Structures
{
first_name: ‘Paul’,
surname: ‘Miller’,
cell: ‘+447557505611’
city: ‘London’,
location: [45.123,47.232],
Profession: [banking, finance, trader],
cars: [
{ model: ‘Bentley’,
year: 1973,
value: 100000, … },
{ model: ‘Rolls Royce’,
year: 1965,
value: 330000, … }
]
}
Fields can contain an array of sub-
documents
Fields
Typed field values
Fields can contain
arrays
11
Document Model Benefits
Agility and flexibility
Data model supports business change
Rapidly iterate to meet new requirements
Intuitive, natural data representation
Eliminates ORM layer
Developers are more productive
Reduces the need for joins, disk seeks
Programming is more simple
Performance delivered at scale
{
_id : ObjectId("4c4ba5e5e8aabf3"),
employee_name: "Dunham, Justin",
department : "Marketing",
title : "Product Manager, Web",
report_up: "Neray, Graham",
pay_band: “C",
benefits : [
{ type : "Health",
plan : "PPO Plus" },
{ type : "Dental",
plan : "Standard" }
]
}
Dynamic Schema
{
policyNum: 123,
type: auto,
customerId: abc,
payment: 899,
deductible: 500,
make: Taurus,
model: Ford,
VIN: 123ABC456,
}
{
policyNum: 456,
type: life,
customerId: efg,
payment: 240,
policyValue: 125000,
start: jan, 1995
end: jan, 2015
}
{
policyNum: 789,
type: home,
customerId: hij,
payment: 650,
deductible: 1000,
floodCoverage: No,
street: “10 Maple Lane”,
city: “Springfield”,
state: “Maryland”
}
Query Operators
Conditional Operators
$all, $exists, $mod, $ne, $in, $nin, $nor, $or, $size,
$type
$lt, $lte, $gt, $gte
// find customers with any claims
> db.customers.find( {claims: {$exists: true }} )
// find customers matching a regular expression
> db.customers.find( {last: /^rog*/i } )
// count customers by city
> db.customers.find( {city: ‘Philadelphia’} ).count()
14
Indexes
// Index nested documents
> db.customers.ensureIndex({“policies.agent”:1} )
> db.customers.find({‘policies.agent’:’Fred’})
// geospatial index
> db.customers.ensureIndex({“property.location”: “2d” } )
> db.customers.find({“property.location” : { $near : [22,42] }} )
// text index
> db.customers.ensureIndex({“policies.notes”: “text” } )
MongoDB is Fully Featured
Spring Framework
Not just a framework!
17
Spring Framework
Spring Projects
Spring & MongoDB
Same Tree?
Let's put these 2 to work!
Build a "cool" App
MongoDB + Spring
24
Nice and simple
25
Video Catalog App
• All videos from our Education platform
– Yes, we have the coolest framework ever for
remote education!
https://university.mongodb.com/
26
Video Catalog App
• All videos from our Education platform
– Yes, we have the coolest framework ever for
remote education!
• Load information into MongoDB
• Allow people to vote on videos
• Find videos based on the metadata
• All using Spring Projects
– Let's also look into optimizations
27
Stack
MongoDB
DAL – Database Access Layer
demo.springio.batch REST API
CODE, CODE, CODE
29
DAL
• Decoupling Database
– Rule n1 on good Software Development
• Base Library
• Simple
30
Batch
• Batch Configuration Class
– reader()
– writer()
@Configuration
@EnableBatchProcessing
• ItemProcessor()
– Excellent way to do pre-aggregations,
computations…
31
Batch
• Things to look for
– chunk(chunkSize)
• Keep an eye on this value to optmise the loading
process
– writer()
• MongoDB bulk insert is here to help
32
REST API
@RestController
@RequestMapping("/…")
@EnableAutoConfiguration
… extends MongoRepository<T, I>
33
REST API
• Things to have in mind
– MongoRepository is "just" CRUD repository
• Need to autowire MongoTemplate to aggregate
– Updates
• Not a particular issue of SpringData
• General thing of ODM's
http://1.bp.blogspot.com/-H40bE-rJUqk/UXo3YatYjqI/AAAAAAAAAho/zjrQVk3WrNA/s1600/paella_03.jpg
Take Ways
35
Recap
• Spring has a lot of things out of the box that we do not
need to reinvent the all the time
• MongoDB can easily be integrated with existing Spring
based projects
• Performance is important
• Continuous Improvement is key!
36
Recap
• DOCUMENTATION!
– Awesome and complete on both projects!
We love enterprise!
38
MongoDB 3.0 is here!
http://www.humanandnatural.com/data/media/178/badan_jaran_desert_oasis_china.jpg
http://www.tinypm.com/blog/wp-content/uploads/2015/01/hammer.jpg
Fully Available!
3.0.2 https://www.mongodb.org/downloads
http://www.mongodb.com/norberto
40
Register now: mongodbworld.com
Early Bird Ends May 1!
Use Code NorbertoLeite for additional 25% Off
*Come as a group of 3 or more – Save another 25%
We’re Always Looking for Top Talent
What are employees saying?
“Working with a group of individuals who you know will have your back is
one of the reasons I love working at MongoDB”
“Every day, we get to solve hard problems that make distributed databases
more accessible to developers all over the world”
“MongoDB lets you tackle real problems that affect hundreds of thousands
of users”
Visit us at www.mongodb.com/careers to see a full
list of opportunities or email your resume to
norberto@mongodb.com
What are we hiring for?
• Technical Services Engineers (Dublin)
• Consulting Engineers (UK OR France)
• Solution Architects (France, Spain, Germany)
• Enterprise Account Executives ( France, Italy, UK, Germany)
• Corporate Account Executives (Dublin)
• Renewals Account Managers (Dublin)
Same Tree!!!
http://www.humanandnatural.com/data/media/178/badan_jaran_desert_oasis_china.jpg
Questions?
@nleite
norberto@mongodb.com
MongoDB + Spring

More Related Content

What's hot (20)

PDF
MongoDB .local Toronto 2019: MongoDB Atlas Search Deep Dive
MongoDB
 
PPTX
How Thermo Fisher Is Reducing Mass Spectrometry Experiment Times from Days to...
MongoDB
 
PDF
MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB
 
PPTX
MongoDB and Hadoop: Driving Business Insights
MongoDB
 
PPTX
Joins and Other MongoDB 3.2 Aggregation Enhancements
Andrew Morgan
 
PDF
MongoDB .local Munich 2019: Managing a Heterogeneous Stack with MongoDB & SQL
MongoDB
 
PPTX
Back to Basics Webinar 1: Introduction to NoSQL
MongoDB
 
PPT
MongoDB Tick Data Presentation
MongoDB
 
PDF
MongoDB .local Chicago 2019: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB
 
PPTX
Doing Joins in MongoDB: Best Practices for Using $lookup
MongoDB
 
PDF
MongoDB .local Munich 2019: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB
 
KEY
CouchDB : More Couch
delagoya
 
PDF
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
MongoDB
 
PDF
Blazing Fast Analytics with MongoDB & Spark
MongoDB
 
ODP
Introduction to MongoDB
Dineesha Suraweera
 
PDF
Spark and MongoDB
Norberto Leite
 
PDF
Using MongoDB + Hadoop Together
MongoDB
 
PPTX
Webinar: The Anatomy of the Cloudant Data Layer
IBM Cloud Data Services
 
PDF
MongoDB World 2019: Raiders of the Anti-patterns: A Journey Towards Fixing Sc...
MongoDB
 
PPTX
Database Trends for Modern Applications: Why the Database You Choose Matters
MongoDB
 
MongoDB .local Toronto 2019: MongoDB Atlas Search Deep Dive
MongoDB
 
How Thermo Fisher Is Reducing Mass Spectrometry Experiment Times from Days to...
MongoDB
 
MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB
 
MongoDB and Hadoop: Driving Business Insights
MongoDB
 
Joins and Other MongoDB 3.2 Aggregation Enhancements
Andrew Morgan
 
MongoDB .local Munich 2019: Managing a Heterogeneous Stack with MongoDB & SQL
MongoDB
 
Back to Basics Webinar 1: Introduction to NoSQL
MongoDB
 
MongoDB Tick Data Presentation
MongoDB
 
MongoDB .local Chicago 2019: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB
 
Doing Joins in MongoDB: Best Practices for Using $lookup
MongoDB
 
MongoDB .local Munich 2019: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB
 
CouchDB : More Couch
delagoya
 
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
MongoDB
 
Blazing Fast Analytics with MongoDB & Spark
MongoDB
 
Introduction to MongoDB
Dineesha Suraweera
 
Spark and MongoDB
Norberto Leite
 
Using MongoDB + Hadoop Together
MongoDB
 
Webinar: The Anatomy of the Cloudant Data Layer
IBM Cloud Data Services
 
MongoDB World 2019: Raiders of the Anti-patterns: A Journey Towards Fixing Sc...
MongoDB
 
Database Trends for Modern Applications: Why the Database You Choose Matters
MongoDB
 

Viewers also liked (19)

PDF
How To Get Hadoop App Intelligence with Driven
Cascading
 
PDF
Advanced MongoDB Aggregation Pipelines
Tom Schreiber
 
PPTX
Data Distribution Theory
William LaForest
 
PPTX
Advanced applications with MongoDB
Norberto Leite
 
PDF
Analyse Yourself
Norberto Leite
 
PDF
OPENEXPO Madrid 2015 - Advanced Applications with MongoDB
MongoDB
 
PPTX
MongoDB + Java + Spring Data
Anton Sulzhenko
 
PPTX
Data Treatment MongoDB
Norberto Leite
 
PDF
Geospatial and MongoDB
Norberto Leite
 
PDF
MongoDB and Python
Norberto Leite
 
PDF
MongoDB and Node.js
Norberto Leite
 
PPTX
MongoDB on Financial Services Sector
Norberto Leite
 
PDF
MongoDB Certification Study Group - May 2016
Norberto Leite
 
PPTX
From Monolithic to Microservices in 45 Minutes
MongoDB
 
PDF
How Financial Services Organizations Use MongoDB
MongoDB
 
PPTX
Mongo+java (1)
MongoDB
 
PPTX
Spring Data, Jongo & Co.
Tobias Trelle
 
PDF
Java Persistence Frameworks for MongoDB
MongoDB
 
PPTX
Retail Reference Architecture
MongoDB
 
How To Get Hadoop App Intelligence with Driven
Cascading
 
Advanced MongoDB Aggregation Pipelines
Tom Schreiber
 
Data Distribution Theory
William LaForest
 
Advanced applications with MongoDB
Norberto Leite
 
Analyse Yourself
Norberto Leite
 
OPENEXPO Madrid 2015 - Advanced Applications with MongoDB
MongoDB
 
MongoDB + Java + Spring Data
Anton Sulzhenko
 
Data Treatment MongoDB
Norberto Leite
 
Geospatial and MongoDB
Norberto Leite
 
MongoDB and Python
Norberto Leite
 
MongoDB and Node.js
Norberto Leite
 
MongoDB on Financial Services Sector
Norberto Leite
 
MongoDB Certification Study Group - May 2016
Norberto Leite
 
From Monolithic to Microservices in 45 Minutes
MongoDB
 
How Financial Services Organizations Use MongoDB
MongoDB
 
Mongo+java (1)
MongoDB
 
Spring Data, Jongo & Co.
Tobias Trelle
 
Java Persistence Frameworks for MongoDB
MongoDB
 
Retail Reference Architecture
MongoDB
 
Ad

Similar to MongoDB + Spring (20)

PDF
MongodB Internals
Norberto Leite
 
PPTX
Introduction to MongoDB
MongoDB
 
PDF
Mongodb Spring
Norberto Leite
 
PPTX
Java Persistence Frameworks for MongoDB
Tobias Trelle
 
PDF
Introduction to MongoDB
Mike Dirolf
 
PDF
Building your first app with MongoDB
Norberto Leite
 
PDF
Mongo db eveningschemadesign
MongoDB APAC
 
PDF
MongoDB FabLab León
Juan Antonio Roy Couto
 
PDF
MongoDB Introduction talk at Dr Dobbs Conference, MongoDB Evenings at Bangalo...
Prasoon Kumar
 
PDF
MongoDB Meetup
Maxime Beugnet
 
PPTX
MongoDB
Anthony Slabinck
 
PDF
MongoDB.pdf
KuldeepKumar778733
 
PPTX
Morphia, Spring Data & Co.
Tobias Trelle
 
PDF
Building Your First MongoDB Application
Tugdual Grall
 
PDF
Confluent & MongoDB APAC Lunch & Learn
confluent
 
PDF
SpringPeople Introduction to MongoDB Administration
SpringPeople
 
PDF
MongoDB for Coder Training (Coding Serbia 2013)
Uwe Printz
 
PPTX
MongoDB Evenings Minneapolis: MongoDB is Cool But When Should I Use It?
MongoDB
 
PDF
MongoDB: a gentle, friendly overview
Antonio Pintus
 
PDF
RESTful Web API and MongoDB go for a pic nic
Nicola Iarocci
 
MongodB Internals
Norberto Leite
 
Introduction to MongoDB
MongoDB
 
Mongodb Spring
Norberto Leite
 
Java Persistence Frameworks for MongoDB
Tobias Trelle
 
Introduction to MongoDB
Mike Dirolf
 
Building your first app with MongoDB
Norberto Leite
 
Mongo db eveningschemadesign
MongoDB APAC
 
MongoDB FabLab León
Juan Antonio Roy Couto
 
MongoDB Introduction talk at Dr Dobbs Conference, MongoDB Evenings at Bangalo...
Prasoon Kumar
 
MongoDB Meetup
Maxime Beugnet
 
MongoDB.pdf
KuldeepKumar778733
 
Morphia, Spring Data & Co.
Tobias Trelle
 
Building Your First MongoDB Application
Tugdual Grall
 
Confluent & MongoDB APAC Lunch & Learn
confluent
 
SpringPeople Introduction to MongoDB Administration
SpringPeople
 
MongoDB for Coder Training (Coding Serbia 2013)
Uwe Printz
 
MongoDB Evenings Minneapolis: MongoDB is Cool But When Should I Use It?
MongoDB
 
MongoDB: a gentle, friendly overview
Antonio Pintus
 
RESTful Web API and MongoDB go for a pic nic
Nicola Iarocci
 
Ad

More from Norberto Leite (16)

PDF
Data Modelling for MongoDB - MongoDB.local Tel Aviv
Norberto Leite
 
PPTX
Avoid Query Pitfalls
Norberto Leite
 
PDF
Mongo db 3.4 Overview
Norberto Leite
 
PDF
MongoDB WiredTiger Internals
Norberto Leite
 
PDF
MongoDB 3.2 Feature Preview
Norberto Leite
 
PDF
MongoDB: Agile Combustion Engine
Norberto Leite
 
PDF
MongoDB Capacity Planning
Norberto Leite
 
PDF
Python and MongoDB
Norberto Leite
 
PDF
Strongly Typed Languages and Flexible Schemas
Norberto Leite
 
PDF
Effectively Deploying MongoDB on AEM
Norberto Leite
 
PPTX
MongoDB Ops Manager
Norberto Leite
 
PDF
Let the Tiger Roar - MongoDB 3.0
Norberto Leite
 
PPTX
MongoDB + Java - Everything you need to know
Norberto Leite
 
PPTX
MongoDB Capacity Planning
Norberto Leite
 
PDF
Aggregation Framework MongoDB Days Munich
Norberto Leite
 
PDF
MongoDB 2.6 is great but what about 2.8?
Norberto Leite
 
Data Modelling for MongoDB - MongoDB.local Tel Aviv
Norberto Leite
 
Avoid Query Pitfalls
Norberto Leite
 
Mongo db 3.4 Overview
Norberto Leite
 
MongoDB WiredTiger Internals
Norberto Leite
 
MongoDB 3.2 Feature Preview
Norberto Leite
 
MongoDB: Agile Combustion Engine
Norberto Leite
 
MongoDB Capacity Planning
Norberto Leite
 
Python and MongoDB
Norberto Leite
 
Strongly Typed Languages and Flexible Schemas
Norberto Leite
 
Effectively Deploying MongoDB on AEM
Norberto Leite
 
MongoDB Ops Manager
Norberto Leite
 
Let the Tiger Roar - MongoDB 3.0
Norberto Leite
 
MongoDB + Java - Everything you need to know
Norberto Leite
 
MongoDB Capacity Planning
Norberto Leite
 
Aggregation Framework MongoDB Days Munich
Norberto Leite
 
MongoDB 2.6 is great but what about 2.8?
Norberto Leite
 

MongoDB + Spring

Editor's Notes

  • #8: MongoDB provides agility, scalability, and performance without sacrificing the functionality of relational databases, like full index support and rich queries Indexes: secondary, compound, text search, geospatial, and more
  • #10: Here we have greatly reduced the relational data model for this application to two tables. In reality no database has two tables. It is much more common to have hundreds or thousands of tables. And as a developer where do you begin when you have a complex data model?? If you’re building an app you’re really thinking about just a hand full of common things, like products, and these can be represented in a document much more easily that a complex relational model where the data is broken up in a way that doesn’t really reflect the way you think about the data or write an application.
  • #16: Rich queries, text search, geospatial, aggregation, mapreduce are types of things you can build based on the richness of the query model.
  • #19: Spring is more than just a framework today Is a set of projects built to make it easier for developers to build smarter applications We will be looking into: Spring Boot Spring Data Spring Batch Spring framework
  • #21: Which tree? Opensource tree The integration tree The flexibility tree The productivity tree
  • #43: Which tree? Opensource tree The integration tree The flexibility tree The productivity tree