SlideShare a Scribd company logo
1 of 43
NoSQL in Enterprise Java Applications
Patrick Baumgartner
NoSQL Search Roadshow | Munich | 16.04.2013
2
Agenda
• Speaker Profile
• New Demands on Data Access
• New Types of Data Stores
• Polyglot Persistence
• Integrating NoSQL Data Stores
• Spring Data Overview
• Example with MongoDB
• Example with Neo4j
• Highlights and Challenges
• Q & A
3
Speaker Profile
Patrick Baumgartner
• Senior Software Consultant | Partner @ Swiftmind
• Spring Framework, OSGi, Neo4j
• Spring Trainer
• Co-Autor von „OSGi für Praktiker“
• Agile Methodologies & Practices
• Scrum.org Trainer - PSD Java
• @patbaumgartner
4
Swiftmind
Your experts for Enterprise Java
Areas of expertise
• Java EE
• Spring Framework
• OSGi
• Agile Methodologies
• Software Engineering Best Practices
Headquarter
• Zürich, Schweiz
• @swiftmind
• http://www.swiftmind.com
5
New Demands on Data Access
• Structured and
unstructured data
• Massive amounts of data
• Inexpensive horizontal
scaling
• Apps and data in the
cloud
• Social network features
• …
6
New Types of Data Stores
7
NoSQL
Data Size
Data Complexity
Key-Value Stores
Column Family
Document Databases
Graph Databases
Relational Databases
90%
8
One single data store for your application?
Polyglot Persistence
9
Polyglot Persistence
Web Shop
User Sessions Shopping Card Recommendations
Product Catalog Analytics Financial Data
Redis Riak Neo4j
MongoDB Casandra MySQL
10
We are not architects!
Integrating NoSQL Data Stores #1
http://www.flickr.com/photos/sakeeb/4087246274
11
Don’t re-invent the wheel!
Integrating NoSQL Data Stores #2
http://www.flickr.com/photos/dmott9/5921728819
12
Let’s use Spring!
Integrating NoSQL Data Stores #3
http://www.springsource.org/spring-data
13
Spring Data
• Same goals as the Spring Framework
– Productivity improvement
– Programming model consistency
– Portability
• Umbrella for subprojects, specific to a given database
• Mapping support for Java domain objects
• http://www.springsource.org/spring-data
• http://github.com/SpringSource/spring-data-XXX
14
Spring Data – Overview #1
• JPA
• JDBC Extensions
Relational Databases
• Apache Hadoop
Big Data
• GemFire
Data Grid
• REST
HTTP
• Redis
Key Value Stores
15
Spring Data – Overview #2
• Mongo DB
• Couchbase *
Document Stores
• Neo4J
Graph Databases
• Hbase
Column Stores
• Apache Solr *
• Elastic Search *
Search
• Commons
Common Infrastructure
* Community Project
16
Spring Data – Key Features
• Low level data access API abstraction
– MongoTemplate, RiakTemplate, Neo4jTemplate …
– Exception translation
– Transaction management
• Object Mapping (Java to data store)
• Generic Repository Support
– Basic CRUD, dynamic finders, pagination and sorting
• Spring namespaces
• Cross Store Persistence Programming Model
– @Entity, @Document, @NodeEntity …
17
Spring Data MongoDB – Example
18
Documents
Stored JSON:
{ "_id" : ObjectId("4f9886290364b533b3acd4ce"),
"_class" : "com.acme.hello.domain.Person",
"name" : "Bob",
"age" : 33
}
19
Spring Data MongoDB – Document
Stored JSON:
{ "_id" : ObjectId("4f9886290364b533b3acd4ce"),
"_class" : "com.example.Person",
"name" : "Bob",
"age" : 33
}
@Document
public class Person {
@Id
private int id;
private String name;
private int age;
// getters/setters…
}
20
Spring Data MongoDB – Configuration
21
Spring Data MongoDB – Repository
@Repository
public class MongoPersonRepository implements BaseRepository<Person> {
@Autowired
MongoOperations mongoTemplate;
Person createPerson(String name, int age){
if(!mongoTemplate.collectionExists(Person.class)){
mongoTemplate.createCollection(Person.class);
}
Person p = new Person(name, age);
mongoTemplate.insert(p)
return p;
}
...
}
22
Spring Data MongoDB – Repository #2
@Repository
public interface MongoPersonRepository implements CrudRepository<Person, Long>
{
Page<Person> findByNameContaining(String name, Pageable p);
@Query("{ ?0 : ?1 }")
List<Product> findByAttributes(String key, String value);
}
23
Spring Data Neo4j – Example
24
Graph
25
Social Data
Alice
Carol Luke
Bob
Sam
Pete
26
The only use case?
Social Graph
27
Spatial Data
1
2 5
3
13
8
type:Hotel
name:Radisson Blu
lat:47.452549
long:8.564615
type:Hotel
name:Widder
lat:47.373517
long:8.539252
28
Social & Spatial Data
Alice
Mat 5
Bob
13
8
type:Hotel
name:Radisson Blu
lat:47.452549
long:8.564615
29
Financial Data
Alice
Hotel Luke
Bank
ATM
Pete
30
Your business domain
Proces
s
KPI
Device
Activity
Function
Service
31
Spring Data Neo4j (SDN)
• POJOs mapped as nodes or relationships – type safe
• Works directly Database, typically embedded mode
• Data is fetched very fast and lazy
• Stores everything within a @Transaction
• Uses heavily AspectJ magic to enhance the POJOs
• …
32
Spring Data Neo4j – NodeEntity
_type_: com.example.Person
name: "Alice"
age: 42
@NodeEntity
public class Person {
private String name;
private int age;
// getters/setters…
}
Person alice = new Person();
alice.setName("Alice");
alice.setAge(42);
alice.persist();
Node
33
Spring Data Neo4j – Relationship
@RelationshipEntity
public class Knows {
private int sinceYear;
public Knows since(int year) {
this.sinceYear = year;
return this;
}
}
@NodeEntity
public class Person {
public Known knows(Person p) {
return this.relateTo(p, Knows.class, "KNOWS");
}
}
Person alice = ...;
Person bob ...;
alice.knows(bob).since(2012); Alice Bob
KNOWS
since: 2012
34
Spring Data Neo4j – NodeEntity
@NodeEntity
public class Person {
private String name;
private int yearOfBirth;
@RelatedTo(type = "KNOWS", direction = Direction.OUTGOING)
private Set<Person> knownPersons;
public void knows(Person p) {
knownPersons.add(p);
}
public Set<Person> getFriends() {
return knownPersons;
}
}
Person alice = ...;
alice.knows(bob);
alice.knows(carol);
Alice Bob
KNOWS
Carol
KNOWS
35
Spring Data Neo4j – Repository
public interface PersonRepository extends
GraphRepository<Person> {
@Query("start person = {0} match ... return ...")
Iterable<Product> getOwnedServices(Person person);
Iterable<Person> findByName(String name);
Iterable<Person> findByNameLike(String name);
}
@Autowired
PersonRepository personRepository;
Person alice = personRepository.findByName("Alice");
36
Spring Data Neo4j – Querying
• Several possibilities implemented to query the graph
– Neo4j API
– Traversal descriptions
– Graph algorithms
– Index queries
– Cypher queries
37
Highlights and Challenges
38
Highlights
• Vibrating community, great support on mailing lists
• Using the right tool for the right job
• New technologies differentiate our product/service from
competitors
• Sources on github.com – Pull requests for improvements
• Very good overall performance
• We can use Spring!
• Abstraction layer makes “driver” changes easy
39
Challenges
• Developer Onboarding
• Schema changes -> migrations
• Some topics not solved yet -> e.g. versioning
• Not many show cases documented in detail
• Sizing for scaling based on real world measurements
• Massive amount of data
• Several framework and data store releases per year
• Bugs, but no show stoppers
• Keeping documentation up-to-date, data model changes
40
Information from the source
Spring Data
Hive Pig JDBC HBase JPA
Splunk NoSQL Redis BigData
Hadoop Redis Roo Gemfire
MongoDB Neo4j REST exporter
Querydsl Repositories
http://bit.ly/sd-book
41
Use a data model which really matches to your data …
Give it a try!
http://www.flickr.com/photos/juniorvelo/3267647833
42
Q&A
43
Thank you!
Patrick Baumgartner, @patbaumgartner
patrick.baumgartner [at] swiftmind [dot] com
http://www.swiftmind.com @swiftmind

More Related Content

Similar to No Sql in Enterprise Java Applications

How to use NoSQL in Enterprise Java Applications - NoSQL Roadshow Basel
How to use NoSQL in Enterprise Java Applications - NoSQL Roadshow BaselHow to use NoSQL in Enterprise Java Applications - NoSQL Roadshow Basel
How to use NoSQL in Enterprise Java Applications - NoSQL Roadshow BaselPatrick Baumgartner
 
Neo4j Introduction (for Techies)
Neo4j Introduction (for Techies)Neo4j Introduction (for Techies)
Neo4j Introduction (for Techies)Patrick Baumgartner
 
How to use NoSQL in Enterprise Java Applications - NoSQL Roadshow Zurich
How to use NoSQL in Enterprise Java Applications - NoSQL Roadshow ZurichHow to use NoSQL in Enterprise Java Applications - NoSQL Roadshow Zurich
How to use NoSQL in Enterprise Java Applications - NoSQL Roadshow ZurichPatrick Baumgartner
 
Searching Relational Data with Elasticsearch
Searching Relational Data with ElasticsearchSearching Relational Data with Elasticsearch
Searching Relational Data with Elasticsearchsirensolutions
 
Polyglot Persistence with MongoDB and Neo4j
Polyglot Persistence with MongoDB and Neo4jPolyglot Persistence with MongoDB and Neo4j
Polyglot Persistence with MongoDB and Neo4jCorie Pollock
 
Combine Spring Data Neo4j and Spring Boot to quickl
Combine Spring Data Neo4j and Spring Boot to quicklCombine Spring Data Neo4j and Spring Boot to quickl
Combine Spring Data Neo4j and Spring Boot to quicklNeo4j
 
Webinar: General Technical Overview of MongoDB for Dev Teams
Webinar: General Technical Overview of MongoDB for Dev TeamsWebinar: General Technical Overview of MongoDB for Dev Teams
Webinar: General Technical Overview of MongoDB for Dev TeamsMongoDB
 
Building your first app with MongoDB
Building your first app with MongoDBBuilding your first app with MongoDB
Building your first app with MongoDBNorberto Leite
 
MongoDB and Spring - Two leaves of a same tree
MongoDB and Spring - Two leaves of a same treeMongoDB and Spring - Two leaves of a same tree
MongoDB and Spring - Two leaves of a same treeMongoDB
 
MongoDB - An Agile NoSQL Database
MongoDB - An Agile NoSQL DatabaseMongoDB - An Agile NoSQL Database
MongoDB - An Agile NoSQL DatabaseGaurav Awasthi
 
MongoDB Days Germany: Data Processing with MongoDB
MongoDB Days Germany: Data Processing with MongoDBMongoDB Days Germany: Data Processing with MongoDB
MongoDB Days Germany: Data Processing with MongoDBMongoDB
 
MongoDB Schema Design
MongoDB Schema DesignMongoDB Schema Design
MongoDB Schema Designaaronheckmann
 
Who's afraid of front end databases
Who's afraid of front end databasesWho's afraid of front end databases
Who's afraid of front end databasesGil Fink
 
Semi Formal Model for Document Oriented Databases
Semi Formal Model for Document Oriented DatabasesSemi Formal Model for Document Oriented Databases
Semi Formal Model for Document Oriented DatabasesDaniel Coupal
 
Mongo db php_shaken_not_stirred_joomlafrappe
Mongo db php_shaken_not_stirred_joomlafrappeMongo db php_shaken_not_stirred_joomlafrappe
Mongo db php_shaken_not_stirred_joomlafrappeSpyros Passas
 

Similar to No Sql in Enterprise Java Applications (20)

How to use NoSQL in Enterprise Java Applications - NoSQL Roadshow Basel
How to use NoSQL in Enterprise Java Applications - NoSQL Roadshow BaselHow to use NoSQL in Enterprise Java Applications - NoSQL Roadshow Basel
How to use NoSQL in Enterprise Java Applications - NoSQL Roadshow Basel
 
Neo4j Introduction (for Techies)
Neo4j Introduction (for Techies)Neo4j Introduction (for Techies)
Neo4j Introduction (for Techies)
 
How to use NoSQL in Enterprise Java Applications - NoSQL Roadshow Zurich
How to use NoSQL in Enterprise Java Applications - NoSQL Roadshow ZurichHow to use NoSQL in Enterprise Java Applications - NoSQL Roadshow Zurich
How to use NoSQL in Enterprise Java Applications - NoSQL Roadshow Zurich
 
Searching Relational Data with Elasticsearch
Searching Relational Data with ElasticsearchSearching Relational Data with Elasticsearch
Searching Relational Data with Elasticsearch
 
Polyglot Persistence with MongoDB and Neo4j
Polyglot Persistence with MongoDB and Neo4jPolyglot Persistence with MongoDB and Neo4j
Polyglot Persistence with MongoDB and Neo4j
 
Combine Spring Data Neo4j and Spring Boot to quickl
Combine Spring Data Neo4j and Spring Boot to quicklCombine Spring Data Neo4j and Spring Boot to quickl
Combine Spring Data Neo4j and Spring Boot to quickl
 
Webinar: General Technical Overview of MongoDB for Dev Teams
Webinar: General Technical Overview of MongoDB for Dev TeamsWebinar: General Technical Overview of MongoDB for Dev Teams
Webinar: General Technical Overview of MongoDB for Dev Teams
 
Analyse Yourself
Analyse YourselfAnalyse Yourself
Analyse Yourself
 
MongoDB Basics
MongoDB BasicsMongoDB Basics
MongoDB Basics
 
Building your first app with MongoDB
Building your first app with MongoDBBuilding your first app with MongoDB
Building your first app with MongoDB
 
MongoDB and Spring - Two leaves of a same tree
MongoDB and Spring - Two leaves of a same treeMongoDB and Spring - Two leaves of a same tree
MongoDB and Spring - Two leaves of a same tree
 
MongoDB + Spring
MongoDB + SpringMongoDB + Spring
MongoDB + Spring
 
MongoDB - An Agile NoSQL Database
MongoDB - An Agile NoSQL DatabaseMongoDB - An Agile NoSQL Database
MongoDB - An Agile NoSQL Database
 
MongoDB Days Germany: Data Processing with MongoDB
MongoDB Days Germany: Data Processing with MongoDBMongoDB Days Germany: Data Processing with MongoDB
MongoDB Days Germany: Data Processing with MongoDB
 
SQL vs NoSQL
SQL vs NoSQLSQL vs NoSQL
SQL vs NoSQL
 
MongoDB Schema Design
MongoDB Schema DesignMongoDB Schema Design
MongoDB Schema Design
 
Who's afraid of front end databases
Who's afraid of front end databasesWho's afraid of front end databases
Who's afraid of front end databases
 
mongoDB at Visibiz
mongoDB at VisibizmongoDB at Visibiz
mongoDB at Visibiz
 
Semi Formal Model for Document Oriented Databases
Semi Formal Model for Document Oriented DatabasesSemi Formal Model for Document Oriented Databases
Semi Formal Model for Document Oriented Databases
 
Mongo db php_shaken_not_stirred_joomlafrappe
Mongo db php_shaken_not_stirred_joomlafrappeMongo db php_shaken_not_stirred_joomlafrappe
Mongo db php_shaken_not_stirred_joomlafrappe
 

More from Patrick Baumgartner

BED-Con - Tools für den täglichen Kampf als Entwickler
BED-Con - Tools für den täglichen Kampf als EntwicklerBED-Con - Tools für den täglichen Kampf als Entwickler
BED-Con - Tools für den täglichen Kampf als EntwicklerPatrick Baumgartner
 
JFS 2011 - Top 10 Tools & Methoden - Baumgartner, Oehmichen
JFS 2011 - Top 10 Tools & Methoden - Baumgartner, OehmichenJFS 2011 - Top 10 Tools & Methoden - Baumgartner, Oehmichen
JFS 2011 - Top 10 Tools & Methoden - Baumgartner, OehmichenPatrick Baumgartner
 
OSGi für Praktiker - Web Applikationen und verteilte Systeme mit OSGi
OSGi für Praktiker - Web Applikationen und verteilte Systeme mit OSGiOSGi für Praktiker - Web Applikationen und verteilte Systeme mit OSGi
OSGi für Praktiker - Web Applikationen und verteilte Systeme mit OSGiPatrick Baumgartner
 
Pax – Tools für den OSGi Alltag
Pax – Tools für den OSGi AlltagPax – Tools für den OSGi Alltag
Pax – Tools für den OSGi AlltagPatrick Baumgartner
 

More from Patrick Baumgartner (7)

Customer is king
Customer is kingCustomer is king
Customer is king
 
BED-Con - Tools für den täglichen Kampf als Entwickler
BED-Con - Tools für den täglichen Kampf als EntwicklerBED-Con - Tools für den täglichen Kampf als Entwickler
BED-Con - Tools für den täglichen Kampf als Entwickler
 
JFS 2011 - Top 10 Tools & Methoden - Baumgartner, Oehmichen
JFS 2011 - Top 10 Tools & Methoden - Baumgartner, OehmichenJFS 2011 - Top 10 Tools & Methoden - Baumgartner, Oehmichen
JFS 2011 - Top 10 Tools & Methoden - Baumgartner, Oehmichen
 
OSGi für Praktiker - Web Applikationen und verteilte Systeme mit OSGi
OSGi für Praktiker - Web Applikationen und verteilte Systeme mit OSGiOSGi für Praktiker - Web Applikationen und verteilte Systeme mit OSGi
OSGi für Praktiker - Web Applikationen und verteilte Systeme mit OSGi
 
Pax – Tools für den OSGi Alltag
Pax – Tools für den OSGi AlltagPax – Tools für den OSGi Alltag
Pax – Tools für den OSGi Alltag
 
OSGi with the Spring Framework
OSGi with the Spring FrameworkOSGi with the Spring Framework
OSGi with the Spring Framework
 
Whats New In Spring 3.0 ?
Whats New In Spring 3.0 ?Whats New In Spring 3.0 ?
Whats New In Spring 3.0 ?
 

Recently uploaded

"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 

Recently uploaded (20)

"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 

No Sql in Enterprise Java Applications

  • 1. NoSQL in Enterprise Java Applications Patrick Baumgartner NoSQL Search Roadshow | Munich | 16.04.2013
  • 2. 2 Agenda • Speaker Profile • New Demands on Data Access • New Types of Data Stores • Polyglot Persistence • Integrating NoSQL Data Stores • Spring Data Overview • Example with MongoDB • Example with Neo4j • Highlights and Challenges • Q & A
  • 3. 3 Speaker Profile Patrick Baumgartner • Senior Software Consultant | Partner @ Swiftmind • Spring Framework, OSGi, Neo4j • Spring Trainer • Co-Autor von „OSGi für Praktiker“ • Agile Methodologies & Practices • Scrum.org Trainer - PSD Java • @patbaumgartner
  • 4. 4 Swiftmind Your experts for Enterprise Java Areas of expertise • Java EE • Spring Framework • OSGi • Agile Methodologies • Software Engineering Best Practices Headquarter • Zürich, Schweiz • @swiftmind • http://www.swiftmind.com
  • 5. 5 New Demands on Data Access • Structured and unstructured data • Massive amounts of data • Inexpensive horizontal scaling • Apps and data in the cloud • Social network features • …
  • 6. 6 New Types of Data Stores
  • 7. 7 NoSQL Data Size Data Complexity Key-Value Stores Column Family Document Databases Graph Databases Relational Databases 90%
  • 8. 8 One single data store for your application? Polyglot Persistence
  • 9. 9 Polyglot Persistence Web Shop User Sessions Shopping Card Recommendations Product Catalog Analytics Financial Data Redis Riak Neo4j MongoDB Casandra MySQL
  • 10. 10 We are not architects! Integrating NoSQL Data Stores #1 http://www.flickr.com/photos/sakeeb/4087246274
  • 11. 11 Don’t re-invent the wheel! Integrating NoSQL Data Stores #2 http://www.flickr.com/photos/dmott9/5921728819
  • 12. 12 Let’s use Spring! Integrating NoSQL Data Stores #3 http://www.springsource.org/spring-data
  • 13. 13 Spring Data • Same goals as the Spring Framework – Productivity improvement – Programming model consistency – Portability • Umbrella for subprojects, specific to a given database • Mapping support for Java domain objects • http://www.springsource.org/spring-data • http://github.com/SpringSource/spring-data-XXX
  • 14. 14 Spring Data – Overview #1 • JPA • JDBC Extensions Relational Databases • Apache Hadoop Big Data • GemFire Data Grid • REST HTTP • Redis Key Value Stores
  • 15. 15 Spring Data – Overview #2 • Mongo DB • Couchbase * Document Stores • Neo4J Graph Databases • Hbase Column Stores • Apache Solr * • Elastic Search * Search • Commons Common Infrastructure * Community Project
  • 16. 16 Spring Data – Key Features • Low level data access API abstraction – MongoTemplate, RiakTemplate, Neo4jTemplate … – Exception translation – Transaction management • Object Mapping (Java to data store) • Generic Repository Support – Basic CRUD, dynamic finders, pagination and sorting • Spring namespaces • Cross Store Persistence Programming Model – @Entity, @Document, @NodeEntity …
  • 17. 17 Spring Data MongoDB – Example
  • 18. 18 Documents Stored JSON: { "_id" : ObjectId("4f9886290364b533b3acd4ce"), "_class" : "com.acme.hello.domain.Person", "name" : "Bob", "age" : 33 }
  • 19. 19 Spring Data MongoDB – Document Stored JSON: { "_id" : ObjectId("4f9886290364b533b3acd4ce"), "_class" : "com.example.Person", "name" : "Bob", "age" : 33 } @Document public class Person { @Id private int id; private String name; private int age; // getters/setters… }
  • 20. 20 Spring Data MongoDB – Configuration
  • 21. 21 Spring Data MongoDB – Repository @Repository public class MongoPersonRepository implements BaseRepository<Person> { @Autowired MongoOperations mongoTemplate; Person createPerson(String name, int age){ if(!mongoTemplate.collectionExists(Person.class)){ mongoTemplate.createCollection(Person.class); } Person p = new Person(name, age); mongoTemplate.insert(p) return p; } ... }
  • 22. 22 Spring Data MongoDB – Repository #2 @Repository public interface MongoPersonRepository implements CrudRepository<Person, Long> { Page<Person> findByNameContaining(String name, Pageable p); @Query("{ ?0 : ?1 }") List<Product> findByAttributes(String key, String value); }
  • 23. 23 Spring Data Neo4j – Example
  • 26. 26 The only use case? Social Graph
  • 27. 27 Spatial Data 1 2 5 3 13 8 type:Hotel name:Radisson Blu lat:47.452549 long:8.564615 type:Hotel name:Widder lat:47.373517 long:8.539252
  • 28. 28 Social & Spatial Data Alice Mat 5 Bob 13 8 type:Hotel name:Radisson Blu lat:47.452549 long:8.564615
  • 31. 31 Spring Data Neo4j (SDN) • POJOs mapped as nodes or relationships – type safe • Works directly Database, typically embedded mode • Data is fetched very fast and lazy • Stores everything within a @Transaction • Uses heavily AspectJ magic to enhance the POJOs • …
  • 32. 32 Spring Data Neo4j – NodeEntity _type_: com.example.Person name: "Alice" age: 42 @NodeEntity public class Person { private String name; private int age; // getters/setters… } Person alice = new Person(); alice.setName("Alice"); alice.setAge(42); alice.persist(); Node
  • 33. 33 Spring Data Neo4j – Relationship @RelationshipEntity public class Knows { private int sinceYear; public Knows since(int year) { this.sinceYear = year; return this; } } @NodeEntity public class Person { public Known knows(Person p) { return this.relateTo(p, Knows.class, "KNOWS"); } } Person alice = ...; Person bob ...; alice.knows(bob).since(2012); Alice Bob KNOWS since: 2012
  • 34. 34 Spring Data Neo4j – NodeEntity @NodeEntity public class Person { private String name; private int yearOfBirth; @RelatedTo(type = "KNOWS", direction = Direction.OUTGOING) private Set<Person> knownPersons; public void knows(Person p) { knownPersons.add(p); } public Set<Person> getFriends() { return knownPersons; } } Person alice = ...; alice.knows(bob); alice.knows(carol); Alice Bob KNOWS Carol KNOWS
  • 35. 35 Spring Data Neo4j – Repository public interface PersonRepository extends GraphRepository<Person> { @Query("start person = {0} match ... return ...") Iterable<Product> getOwnedServices(Person person); Iterable<Person> findByName(String name); Iterable<Person> findByNameLike(String name); } @Autowired PersonRepository personRepository; Person alice = personRepository.findByName("Alice");
  • 36. 36 Spring Data Neo4j – Querying • Several possibilities implemented to query the graph – Neo4j API – Traversal descriptions – Graph algorithms – Index queries – Cypher queries
  • 38. 38 Highlights • Vibrating community, great support on mailing lists • Using the right tool for the right job • New technologies differentiate our product/service from competitors • Sources on github.com – Pull requests for improvements • Very good overall performance • We can use Spring! • Abstraction layer makes “driver” changes easy
  • 39. 39 Challenges • Developer Onboarding • Schema changes -> migrations • Some topics not solved yet -> e.g. versioning • Not many show cases documented in detail • Sizing for scaling based on real world measurements • Massive amount of data • Several framework and data store releases per year • Bugs, but no show stoppers • Keeping documentation up-to-date, data model changes
  • 40. 40 Information from the source Spring Data Hive Pig JDBC HBase JPA Splunk NoSQL Redis BigData Hadoop Redis Roo Gemfire MongoDB Neo4j REST exporter Querydsl Repositories http://bit.ly/sd-book
  • 41. 41 Use a data model which really matches to your data … Give it a try! http://www.flickr.com/photos/juniorvelo/3267647833
  • 43. 43 Thank you! Patrick Baumgartner, @patbaumgartner patrick.baumgartner [at] swiftmind [dot] com http://www.swiftmind.com @swiftmind

Editor's Notes

  1. Spring Data repositories can be composed with interfacesThe implementation is magically provided by Spring Data