SlideShare a Scribd company logo
1 of 28
How to Use NoSQL
in Enterprise Java Applications




Patrick Baumgartner

NoSQL Roadshow | Basel | 30.08.2012
Agenda

•   Speaker Profile
•   New Demands on Data Access
•   New Types of Data Stores
•   Integrating NoSQL Data Stores
•   Spring Data Overview
•   Example with MongoDB
•   Example with Neo4j
•   Q&A




                                    2
Speaker Profile

Patrick Baumgartner
•   Senior Software Consultant | Partner
•   VMware/SpringSource Certified Instructor (Spring Trainer)
•   Spring Framework, OSGi & agile engineering practices
•   Co-author of „OSGi für Praktiker“ (Hanser)


Swiftmind GmbH http://www.swiftmind.com
• Enterprise Java, Spring & OSGi consulting
• Spring & OSGi workshops & trainings
• Agile engineering practices workshops


                                                                3
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
                  • …




                                              4
New Types of Data Stores




                           5
Integrating NoSQL Data Stores #1
We are not architects!




                            http://www.flickr.com/photos/sakeeb/4087246274


                                                                        6
Integrating NoSQL Data Stores #2
Don’t re-invent the wheel!




                             http://www.flickr.com/photos/dmott9/5921728819


                                                                         7
Integrating NoSQL Data Stores #3
Let’s use Spring!




                              http://www.springsource.org/spring-data


                                                                   8
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

                                                           9
Spring Data – Overview #1

  Relational Databases
  • JPA
  • JDBC Extensions

  Big Data
  • Apache Hadoop

  Data Grid
  • GemFire

  HTTP
  • REST

                            10
Spring Data – Overview #2

  Key Value Stores
  • Redis

  Document Stores
  • Mongo DB

  Graph Databases
  • Neo4J

  Column Stores
  • HBase

  Common Infrastructure
  • Commons

                            11
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



                                                           12
Spring Data MongoDB – Example




                                13
Documents



            Stored JSON:
            { "_id" : ObjectId("4f9886290364b533b3acd4ce"),
              "_class" : "com.acme.hello.domain.Person",
              "name" : "Bob",
              "age" : 33
            }




                                                         14
Spring Data MongoDB – Document

@Document
public class Person {
  @Id
                         Stored JSON:
  private int id;        { "_id" : ObjectId("4f9886290364b533b3acd4ce"),
                           "_class" : "com.example.Person",
  private String name;     "name" : "Bob",
  private int age;         "age" : 33
                         }
  // getters/setters…
}




                                                                      15
Spring Data MongoDB – Configuration




                                      16
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;
    }


    ...
}



                                                                         17
Spring Data Neo4j – Example




                              18
Graph




        19
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
•   …




                                                         20
Spring Data Neo4j – Entity

@NodeEntity
                                 Node
public class Person {
  private String name;
  private int age;             _type_: com.example.Person
                               name: "Alice"
  // getters/setters…          age: 42

}

Person alice = new Person();
alice.setName("Alice");
alice.setAge(42);
alice.persist();

                                                            21
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() {                   KNOWS
   return knownPersons;                   Alice                    Bob
 }
}
Person alice = ...;
alice.knows(bob);
alice.knows(carol);                          KNOWS
                                                               Carol


                                                                         22
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 ...;                                      KNOWS
alice.knows(bob).since(2012);         Alice                        Bob
                                                     since: 2012

                                                                     23
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");



                                                         24
Spring Data Neo4j – Querying

• Several possibilities implemented to query the graph
   – Neo4j API
   – Traversal descriptions
   – Graph algorithms
   – Index queries
   – Cypher queries




                                                         25
Give it a try!
Use a data model which really matches to your data …




                                           http://www.flickr.com/photos/juniorvelo/3267647833


                                                                                         26
05.09.2012 /ch/open Workshop-Tage
NoSQL für Java Enterprise Anwendungen mit Spring Data




                                         4th – 6th September



                                          http://www.flickr.com/photos/4nitsirk/5211251578


                                                                                      27
Q&A




Patrick Baumgartner
patrick.baumgartner [at] swiftmind [dot] com
http://www.swiftmind.com http://www.twitter.com/patbaumgartner


                                                            28

More Related Content

What's hot

Cross-Platform Mobile Apps & Drupal Web Services
Cross-Platform Mobile Apps & Drupal Web ServicesCross-Platform Mobile Apps & Drupal Web Services
Cross-Platform Mobile Apps & Drupal Web ServicesBob Sims
 
Session 2 - NGSI-LD primer & Smart Data Models | Train the Trainers Program
Session 2 - NGSI-LD primer & Smart Data Models | Train the Trainers ProgramSession 2 - NGSI-LD primer & Smart Data Models | Train the Trainers Program
Session 2 - NGSI-LD primer & Smart Data Models | Train the Trainers ProgramFIWARE
 
Contextual Computing - Knowledge Graphs & Web of Entities
Contextual Computing - Knowledge Graphs & Web of EntitiesContextual Computing - Knowledge Graphs & Web of Entities
Contextual Computing - Knowledge Graphs & Web of EntitiesRichard Wallis
 
JSON-LD update DC 2017
JSON-LD update DC 2017JSON-LD update DC 2017
JSON-LD update DC 2017Gregg Kellogg
 
Knowledge discoverylaurahollink
Knowledge discoverylaurahollinkKnowledge discoverylaurahollink
Knowledge discoverylaurahollinkSSSW
 
Neo4j Introduction (for Techies)
Neo4j Introduction (for Techies)Neo4j Introduction (for Techies)
Neo4j Introduction (for Techies)Patrick Baumgartner
 
A general introduction to Spring Data / Neo4J
A general introduction to Spring Data / Neo4JA general introduction to Spring Data / Neo4J
A general introduction to Spring Data / Neo4JFlorent Biville
 
The Web of Data is Our Opportunity
The Web of Data is Our OpportunityThe Web of Data is Our Opportunity
The Web of Data is Our OpportunityRichard Wallis
 
Introduction to BioHackathon 2014
Introduction to BioHackathon 2014Introduction to BioHackathon 2014
Introduction to BioHackathon 2014Toshiaki Katayama
 
Identifying The Benefit of Linked Data
Identifying The Benefit of Linked DataIdentifying The Benefit of Linked Data
Identifying The Benefit of Linked DataRichard Wallis
 
dataviz on d3.js + elasticsearch
dataviz on d3.js + elasticsearchdataviz on d3.js + elasticsearch
dataviz on d3.js + elasticsearchMathieu Elie
 
Back to Basics Webinar 3: Schema Design Thinking in Documents
 Back to Basics Webinar 3: Schema Design Thinking in Documents Back to Basics Webinar 3: Schema Design Thinking in Documents
Back to Basics Webinar 3: Schema Design Thinking in DocumentsMongoDB
 
MongoDB Schema Design (Richard Kreuter's Mongo Berlin preso)
MongoDB Schema Design (Richard Kreuter's Mongo Berlin preso)MongoDB Schema Design (Richard Kreuter's Mongo Berlin preso)
MongoDB Schema Design (Richard Kreuter's Mongo Berlin preso)MongoDB
 
Session 5 - NGSI-LD Advanced Operations | Train the Trainers Program
Session 5 -  NGSI-LD Advanced Operations | Train the Trainers ProgramSession 5 -  NGSI-LD Advanced Operations | Train the Trainers Program
Session 5 - NGSI-LD Advanced Operations | Train the Trainers ProgramFIWARE
 
The nature.com ontologies portal: nature.com/ontologies
The nature.com ontologies portal: nature.com/ontologiesThe nature.com ontologies portal: nature.com/ontologies
The nature.com ontologies portal: nature.com/ontologiesTony Hammond
 
Choosing the right NOSQL database
Choosing the right NOSQL databaseChoosing the right NOSQL database
Choosing the right NOSQL databaseTobias Lindaaker
 
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
 
DH11: Browsing Highly Interconnected Humanities Databases Through Multi-Resul...
DH11: Browsing Highly Interconnected Humanities Databases Through Multi-Resul...DH11: Browsing Highly Interconnected Humanities Databases Through Multi-Resul...
DH11: Browsing Highly Interconnected Humanities Databases Through Multi-Resul...Michele Pasin
 

What's hot (20)

Cross-Platform Mobile Apps & Drupal Web Services
Cross-Platform Mobile Apps & Drupal Web ServicesCross-Platform Mobile Apps & Drupal Web Services
Cross-Platform Mobile Apps & Drupal Web Services
 
Session 2 - NGSI-LD primer & Smart Data Models | Train the Trainers Program
Session 2 - NGSI-LD primer & Smart Data Models | Train the Trainers ProgramSession 2 - NGSI-LD primer & Smart Data Models | Train the Trainers Program
Session 2 - NGSI-LD primer & Smart Data Models | Train the Trainers Program
 
Danbri Drupalcon Export
Danbri Drupalcon ExportDanbri Drupalcon Export
Danbri Drupalcon Export
 
Contextual Computing - Knowledge Graphs & Web of Entities
Contextual Computing - Knowledge Graphs & Web of EntitiesContextual Computing - Knowledge Graphs & Web of Entities
Contextual Computing - Knowledge Graphs & Web of Entities
 
JSON-LD update DC 2017
JSON-LD update DC 2017JSON-LD update DC 2017
JSON-LD update DC 2017
 
Knowledge discoverylaurahollink
Knowledge discoverylaurahollinkKnowledge discoverylaurahollink
Knowledge discoverylaurahollink
 
Neo4j Introduction (for Techies)
Neo4j Introduction (for Techies)Neo4j Introduction (for Techies)
Neo4j Introduction (for Techies)
 
A general introduction to Spring Data / Neo4J
A general introduction to Spring Data / Neo4JA general introduction to Spring Data / Neo4J
A general introduction to Spring Data / Neo4J
 
The Web of Data is Our Opportunity
The Web of Data is Our OpportunityThe Web of Data is Our Opportunity
The Web of Data is Our Opportunity
 
Introduction to BioHackathon 2014
Introduction to BioHackathon 2014Introduction to BioHackathon 2014
Introduction to BioHackathon 2014
 
Identifying The Benefit of Linked Data
Identifying The Benefit of Linked DataIdentifying The Benefit of Linked Data
Identifying The Benefit of Linked Data
 
dataviz on d3.js + elasticsearch
dataviz on d3.js + elasticsearchdataviz on d3.js + elasticsearch
dataviz on d3.js + elasticsearch
 
Back to Basics Webinar 3: Schema Design Thinking in Documents
 Back to Basics Webinar 3: Schema Design Thinking in Documents Back to Basics Webinar 3: Schema Design Thinking in Documents
Back to Basics Webinar 3: Schema Design Thinking in Documents
 
MongoDB Schema Design (Richard Kreuter's Mongo Berlin preso)
MongoDB Schema Design (Richard Kreuter's Mongo Berlin preso)MongoDB Schema Design (Richard Kreuter's Mongo Berlin preso)
MongoDB Schema Design (Richard Kreuter's Mongo Berlin preso)
 
Session 5 - NGSI-LD Advanced Operations | Train the Trainers Program
Session 5 -  NGSI-LD Advanced Operations | Train the Trainers ProgramSession 5 -  NGSI-LD Advanced Operations | Train the Trainers Program
Session 5 - NGSI-LD Advanced Operations | Train the Trainers Program
 
The nature.com ontologies portal: nature.com/ontologies
The nature.com ontologies portal: nature.com/ontologiesThe nature.com ontologies portal: nature.com/ontologies
The nature.com ontologies portal: nature.com/ontologies
 
Swoogle
SwoogleSwoogle
Swoogle
 
Choosing the right NOSQL database
Choosing the right NOSQL databaseChoosing the right NOSQL database
Choosing the right NOSQL database
 
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
 
DH11: Browsing Highly Interconnected Humanities Databases Through Multi-Resul...
DH11: Browsing Highly Interconnected Humanities Databases Through Multi-Resul...DH11: Browsing Highly Interconnected Humanities Databases Through Multi-Resul...
DH11: Browsing Highly Interconnected Humanities Databases Through Multi-Resul...
 

Similar to How to use NoSQL in Enterprise Java Applications - NoSQL Roadshow Basel

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
 
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
 
Spring Up Your Graph
Spring Up Your GraphSpring Up Your Graph
Spring Up Your GraphVMware Tanzu
 
Polyglot Persistence with MongoDB and Neo4j
Polyglot Persistence with MongoDB and Neo4jPolyglot Persistence with MongoDB and Neo4j
Polyglot Persistence with MongoDB and Neo4jCorie Pollock
 
Introduction to Graph databases and Neo4j (by Stefan Armbruster)
Introduction to Graph databases and Neo4j (by Stefan Armbruster)Introduction to Graph databases and Neo4j (by Stefan Armbruster)
Introduction to Graph databases and Neo4j (by Stefan Armbruster)barcelonajug
 
Hands On Spring Data
Hands On Spring DataHands On Spring Data
Hands On Spring DataEric Bottard
 
using Spring and MongoDB on Cloud Foundry
using Spring and MongoDB on Cloud Foundryusing Spring and MongoDB on Cloud Foundry
using Spring and MongoDB on Cloud FoundryJoshua Long
 
MongoDB + Java + Spring Data
MongoDB + Java + Spring DataMongoDB + Java + Spring Data
MongoDB + Java + Spring DataAnton Sulzhenko
 
MongoDB - An Agile NoSQL Database
MongoDB - An Agile NoSQL DatabaseMongoDB - An Agile NoSQL Database
MongoDB - An Agile NoSQL DatabaseGaurav Awasthi
 
springdatajpatwjug-120527215242-phpapp02.pdf
springdatajpatwjug-120527215242-phpapp02.pdfspringdatajpatwjug-120527215242-phpapp02.pdf
springdatajpatwjug-120527215242-phpapp02.pdfssuser0562f1
 
Data Abstraction for Large Web Applications
Data Abstraction for Large Web ApplicationsData Abstraction for Large Web Applications
Data Abstraction for Large Web Applicationsbrandonsavage
 
Building a Dataset Search Engine with Spark and Elasticsearch: Spark Summit E...
Building a Dataset Search Engine with Spark and Elasticsearch: Spark Summit E...Building a Dataset Search Engine with Spark and Elasticsearch: Spark Summit E...
Building a Dataset Search Engine with Spark and Elasticsearch: Spark Summit E...Spark Summit
 
Linked Open Data Utrecht University Library
Linked Open Data Utrecht University LibraryLinked Open Data Utrecht University Library
Linked Open Data Utrecht University LibraryRuben Schalk
 
Considerations for using NoSQL technology on your next IT project - Akmal Cha...
Considerations for using NoSQL technology on your next IT project - Akmal Cha...Considerations for using NoSQL technology on your next IT project - Akmal Cha...
Considerations for using NoSQL technology on your next IT project - Akmal Cha...jaxconf
 
Core Data Migrations and A Better Option
Core Data Migrations and A Better OptionCore Data Migrations and A Better Option
Core Data Migrations and A Better OptionPriya Rajagopal
 
Searching Relational Data with Elasticsearch
Searching Relational Data with ElasticsearchSearching Relational Data with Elasticsearch
Searching Relational Data with Elasticsearchsirensolutions
 
Find your data - using GraphDB capabilities in XPages applications - ICS.UG 2016
Find your data - using GraphDB capabilities in XPages applications - ICS.UG 2016Find your data - using GraphDB capabilities in XPages applications - ICS.UG 2016
Find your data - using GraphDB capabilities in XPages applications - ICS.UG 2016ICS User Group
 

Similar to How to use NoSQL in Enterprise Java Applications - NoSQL Roadshow Basel (20)

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
 
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
 
Spring Up Your Graph
Spring Up Your GraphSpring Up Your Graph
Spring Up Your Graph
 
Polyglot Persistence with MongoDB and Neo4j
Polyglot Persistence with MongoDB and Neo4jPolyglot Persistence with MongoDB and Neo4j
Polyglot Persistence with MongoDB and Neo4j
 
Introduction to Graph databases and Neo4j (by Stefan Armbruster)
Introduction to Graph databases and Neo4j (by Stefan Armbruster)Introduction to Graph databases and Neo4j (by Stefan Armbruster)
Introduction to Graph databases and Neo4j (by Stefan Armbruster)
 
Hands On Spring Data
Hands On Spring DataHands On Spring Data
Hands On Spring Data
 
Analyse Yourself
Analyse YourselfAnalyse Yourself
Analyse Yourself
 
using Spring and MongoDB on Cloud Foundry
using Spring and MongoDB on Cloud Foundryusing Spring and MongoDB on Cloud Foundry
using Spring and MongoDB on Cloud Foundry
 
MongoDB + Java + Spring Data
MongoDB + Java + Spring DataMongoDB + Java + Spring Data
MongoDB + Java + Spring Data
 
SQL vs NoSQL
SQL vs NoSQLSQL vs NoSQL
SQL vs NoSQL
 
Neo4j_allHands_04112013
Neo4j_allHands_04112013Neo4j_allHands_04112013
Neo4j_allHands_04112013
 
MongoDB - An Agile NoSQL Database
MongoDB - An Agile NoSQL DatabaseMongoDB - An Agile NoSQL Database
MongoDB - An Agile NoSQL Database
 
springdatajpatwjug-120527215242-phpapp02.pdf
springdatajpatwjug-120527215242-phpapp02.pdfspringdatajpatwjug-120527215242-phpapp02.pdf
springdatajpatwjug-120527215242-phpapp02.pdf
 
Data Abstraction for Large Web Applications
Data Abstraction for Large Web ApplicationsData Abstraction for Large Web Applications
Data Abstraction for Large Web Applications
 
Building a Dataset Search Engine with Spark and Elasticsearch: Spark Summit E...
Building a Dataset Search Engine with Spark and Elasticsearch: Spark Summit E...Building a Dataset Search Engine with Spark and Elasticsearch: Spark Summit E...
Building a Dataset Search Engine with Spark and Elasticsearch: Spark Summit E...
 
Linked Open Data Utrecht University Library
Linked Open Data Utrecht University LibraryLinked Open Data Utrecht University Library
Linked Open Data Utrecht University Library
 
Considerations for using NoSQL technology on your next IT project - Akmal Cha...
Considerations for using NoSQL technology on your next IT project - Akmal Cha...Considerations for using NoSQL technology on your next IT project - Akmal Cha...
Considerations for using NoSQL technology on your next IT project - Akmal Cha...
 
Core Data Migrations and A Better Option
Core Data Migrations and A Better OptionCore Data Migrations and A Better Option
Core Data Migrations and A Better Option
 
Searching Relational Data with Elasticsearch
Searching Relational Data with ElasticsearchSearching Relational Data with Elasticsearch
Searching Relational Data with Elasticsearch
 
Find your data - using GraphDB capabilities in XPages applications - ICS.UG 2016
Find your data - using GraphDB capabilities in XPages applications - ICS.UG 2016Find your data - using GraphDB capabilities in XPages applications - ICS.UG 2016
Find your data - using GraphDB capabilities in XPages applications - ICS.UG 2016
 

More from Patrick Baumgartner

Daten natuerlich modellieren und verarbeiten mit Neo4j
Daten natuerlich modellieren und verarbeiten mit Neo4jDaten natuerlich modellieren und verarbeiten mit Neo4j
Daten natuerlich modellieren und verarbeiten mit Neo4jPatrick 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 (8)

Customer is king
Customer is kingCustomer is king
Customer is king
 
Daten natuerlich modellieren und verarbeiten mit Neo4j
Daten natuerlich modellieren und verarbeiten mit Neo4jDaten natuerlich modellieren und verarbeiten mit Neo4j
Daten natuerlich modellieren und verarbeiten mit Neo4j
 
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

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
 
[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
 
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
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
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
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
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
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
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
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
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
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
🐬 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
 
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
 
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
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
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
 

Recently uploaded (20)

Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 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
 
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...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
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
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
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...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
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
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
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
 
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
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 

How to use NoSQL in Enterprise Java Applications - NoSQL Roadshow Basel

  • 1. How to Use NoSQL in Enterprise Java Applications Patrick Baumgartner NoSQL Roadshow | Basel | 30.08.2012
  • 2. Agenda • Speaker Profile • New Demands on Data Access • New Types of Data Stores • Integrating NoSQL Data Stores • Spring Data Overview • Example with MongoDB • Example with Neo4j • Q&A 2
  • 3. Speaker Profile Patrick Baumgartner • Senior Software Consultant | Partner • VMware/SpringSource Certified Instructor (Spring Trainer) • Spring Framework, OSGi & agile engineering practices • Co-author of „OSGi für Praktiker“ (Hanser) Swiftmind GmbH http://www.swiftmind.com • Enterprise Java, Spring & OSGi consulting • Spring & OSGi workshops & trainings • Agile engineering practices workshops 3
  • 4. 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 • … 4
  • 5. New Types of Data Stores 5
  • 6. Integrating NoSQL Data Stores #1 We are not architects! http://www.flickr.com/photos/sakeeb/4087246274 6
  • 7. Integrating NoSQL Data Stores #2 Don’t re-invent the wheel! http://www.flickr.com/photos/dmott9/5921728819 7
  • 8. Integrating NoSQL Data Stores #3 Let’s use Spring! http://www.springsource.org/spring-data 8
  • 9. 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 9
  • 10. Spring Data – Overview #1 Relational Databases • JPA • JDBC Extensions Big Data • Apache Hadoop Data Grid • GemFire HTTP • REST 10
  • 11. Spring Data – Overview #2 Key Value Stores • Redis Document Stores • Mongo DB Graph Databases • Neo4J Column Stores • HBase Common Infrastructure • Commons 11
  • 12. 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 12
  • 13. Spring Data MongoDB – Example 13
  • 14. Documents Stored JSON: { "_id" : ObjectId("4f9886290364b533b3acd4ce"), "_class" : "com.acme.hello.domain.Person", "name" : "Bob", "age" : 33 } 14
  • 15. Spring Data MongoDB – Document @Document public class Person { @Id Stored JSON: private int id; { "_id" : ObjectId("4f9886290364b533b3acd4ce"), "_class" : "com.example.Person", private String name; "name" : "Bob", private int age; "age" : 33 } // getters/setters… } 15
  • 16. Spring Data MongoDB – Configuration 16
  • 17. 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; } ... } 17
  • 18. Spring Data Neo4j – Example 18
  • 19. Graph 19
  • 20. 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 • … 20
  • 21. Spring Data Neo4j – Entity @NodeEntity Node public class Person { private String name; private int age; _type_: com.example.Person name: "Alice" // getters/setters… age: 42 } Person alice = new Person(); alice.setName("Alice"); alice.setAge(42); alice.persist(); 21
  • 22. 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() { KNOWS return knownPersons; Alice Bob } } Person alice = ...; alice.knows(bob); alice.knows(carol); KNOWS Carol 22
  • 23. 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 ...; KNOWS alice.knows(bob).since(2012); Alice Bob since: 2012 23
  • 24. 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"); 24
  • 25. Spring Data Neo4j – Querying • Several possibilities implemented to query the graph – Neo4j API – Traversal descriptions – Graph algorithms – Index queries – Cypher queries 25
  • 26. Give it a try! Use a data model which really matches to your data … http://www.flickr.com/photos/juniorvelo/3267647833 26
  • 27. 05.09.2012 /ch/open Workshop-Tage NoSQL für Java Enterprise Anwendungen mit Spring Data 4th – 6th September http://www.flickr.com/photos/4nitsirk/5211251578 27
  • 28. Q&A Patrick Baumgartner patrick.baumgartner [at] swiftmind [dot] com http://www.swiftmind.com http://www.twitter.com/patbaumgartner 28

Editor's Notes

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