SlideShare a Scribd company logo
1 of 29
Download to read offline
Spice up Your Graph
Gerrit Meier and Michael Simons
introducing the all new Spring Data Neo4j (SDN 6)
SpringOne 2020
Spring
Introducing SDN 6 at SpringOne 2020 by @meistermeier and @rotnroll666 2
Introducing SDN 6 at SpringOne 2020 by @meistermeier and @rotnroll666 4
Label
Type
Introducing SDN 6 at SpringOne 2020 by @meistermeier and @rotnroll666 5
Person
KNOWS
{
name: "Mr. X"

dob: 26.02.1982
}
{
met: "Spring One"

contact: 03.09.2020
}
Introducing SDN 6 at SpringOne 2020 by @meistermeier and @rotnroll666 6
Person
KNOWS
Person
Topic
INTERESTED_IN INTERESTED_IN
{
term: "Spring Data"

description: " … "
}
Graph Databases
Introducing SDN 6 at SpringOne 2020 by @meistermeier and @rotnroll666 7
Spring Data Neo4j Team
@meistermeier @rotnroll666
What would you do if you could create
yet another object mapper from
scratch?
What would you do if you could create
yet another object mapper from
scratch?
Why
Introducing SDN 6 at SpringOne 2020 by @meistermeier and @rotnroll666 9
Current Spring Data Neoj4 + Neo4j-OGM
• start.spring.io gives you SDN and Neo4j-OGM
• 3 different modes available (Embedded, HTTP and native)
• Makes usage of Cypher harder than necessary
• Custom queries are possible but go all through the Neo4j-OGM
abstraction
• Some building parts stack vertically, some horizontally
➡ Confusing options for beginners
Spring Data Neo4j 6
Introducing SDN 6 at SpringOne 2020 by @meistermeier and @rotnroll666 11
What do we want?
• A composable stack
• Nicely integrated in Spring Boot
• Access at all abstraction levels
• Raw queries (outside application level transactions)
• Raw queries (inside application level transactions)
• Plus ad-hoc mapping
• Mapping
• Repository abstraction
• Reactive (and imperative) database access
Introducing SDN 6 at SpringOne 2020 by @meistermeier and @rotnroll666
• Java Driver
• Direct usage
• Simple Client
• RowMapper-like
• Neo4jTemplate
• Entity-Metadata aware
• Repositories
• DDD way of accessing your data
Multiple, ordered
levels of
Abstraction
Introducing SDN 6 at SpringOne 2020 by @meistermeier and @rotnroll666 13
Spring Data Repositories
Neo4j Template
Neo4j Client
Neo4j Java Driver
spring-boot-starter-data-neo4j
spring-boot-autoconfigure
SDN 6
provides
configures
A composable stack
Introducing SDN 6 at SpringOne 2020 by @meistermeier and @rotnroll666
• Imperative and reactive on par
• New: Reactive transactions
Reactive support
Introducing SDN 6 at SpringOne 2020 by @meistermeier and @rotnroll666
• Bolt protocol
• Driver type system
100%-based on
Neo4j Java Driver
Introducing SDN 6 at SpringOne 2020 by @meistermeier and @rotnroll666 18
@Autowired org.neo4j.driver.Driver
@RestController
public class MoviesController {
private final Driver driver;
public MoviesController(Driver driver) {
this.driver = driver;
}
@GetMapping(path = "/movies", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
public Flux<String> getMovieTitles() {
/# Using an implicit, driver managed transaction
return Flux.usingWhen(
Mono.fromSupplier(driver:%rxSession),
s -' Flux.from(s.run("MATCH (m:Movie) RETURN m ORDER BY m.name ASC").records()),
RxSession:%close
).map(r -' r.get("m").asNode().get("title").asString());
}
}
Based on open standards: Reactive Streams. Can be used with RxJava2, too.
Introducing SDN 6 at SpringOne 2020 by @meistermeier and @rotnroll666
@Service
public class MovieService {
private final ReactiveNeo4jClient client;
public MovieService(ReactiveNeo4jClient client) {
this.client = client;
}
/# Fully integrated with Springs declarative
/# or explicit transactions (via TransactionalOperator or TransactionTemplate)
@Transactional
public Flux<String> getMovieTitles() {
return client.query("MATCH (m:Movie) RETURN m ORDER BY m.name ASC")
.fetchAs(String.class)
.mappedBy((typeSystem, record) -' record.get("m").asNode().get("title").asString())
.all();
}
}
19
@Autowired
org.springframework.data.neo4j.core.ReactiveNeo4jClient
Introducing SDN 6 at SpringOne 2020 by @meistermeier and @rotnroll666 20
@Autowired
org.springframework.data.neo4j.core.ReactiveNeo4jTemplate
@Service
public class MovieService {
private final ReactiveNeo4jTemplate template;
public MovieService(ReactiveNeo4jTemplate template) {
this.template = template;
}
@Transactional
public Flux<String> getMovieTitles() {
/# Overload with custom query available
return template.findAll(MovieEntity.class)
.map(MovieEntity:%getTitle);
}
}
@Node("Movie")
class MovieEntity {
private @Id final String title;
private @Property("tagline") final String description;
@Relationship(type = "ACTED_IN", direction = INCOMING)
private final Map<PersonEntity, Roles> actorsAndRoles;
/# Full immutable class, works also with @Data,
/# Kotlin and JDK 14 records
public MovieEntity(String title, String description,
Map<PersonEntity, Roles> actorsAndRoles
) {
this.title = title;
this.description = description;
this.actorsAndRoles = actorsAndRoles;
}
}
Introducing SDN 6 at SpringOne 2020 by @meistermeier and @rotnroll666
public interface MovieRepository extends ReactiveNeo4jRepository<MovieEntity, String> {}
@Service
public class MovieService {
private final MovieRepository repository;
public MovieService(MovieRepository repository) {
this.repository = repository;
}
@Transactional
public Flux<String> getMovieTitles() {
/# Custom query via @Query on a method
/# For simple cases, use derived query methods
/# repository.findAllByOrderByTitle
return repository.findAll()
.map(MovieEntity:%getTitle);
/# For the first time with Spring Data and Neo4j, query by Example
/# return repository.findAll(Example.of(new MovieEntity("The Matrix", null)));
}
}
21
@Autowired org.springframework.data.neo4j.core.ReactiveNeo4jRepository
Introducing SDN 6 at SpringOne 2020 by @meistermeier and @rotnroll666
• Instances via
• (persistent) constructor
• wither
• setter
• No reflection violating the
contract
Immutable Mapping
Introducing SDN 6 at SpringOne 2020 by @meistermeier and @rotnroll666
• Neo4j Driver Java auto-config
• Properties where they belong
• Updated SDN starter
• Getting you up to speed in a
blink
• Health Checks
• Based on the Java Driver
Spring Boot
integration
Introducing SDN 6 at SpringOne 2020 by @meistermeier and @rotnroll666
@ConfigurationProperties(prefix = "spring.neo4j")
public class Neo4jProperties {
public static class Authentication {
/** The login of the user connecting to the database.**
private String username;
/** The password of the user connecting to the database. **
private String password;
/** The realm to connect to.**
private String realm;
}
/** The uri this driver should connect to. The driver supports bolt or neo4j as schemes.**
private URI uri;
/** The authentication the driver is supposed to use. Maybe null. **
private Authentication authentication = new Authentication();
}
24
Access to all configuration settings
Consistent across frameworks!
Introducing SDN 6 at SpringOne 2020 by @meistermeier and @rotnroll666
Less Surprises
Introducing SDN 6 at SpringOne 2020 by @meistermeier and @rotnroll666
Cypher DSL
• Zero dependency library
• Compile-time checked query
construction
• Re-usable instances
Introducing SDN 6 at SpringOne 2020 by @meistermeier and @rotnroll666 27
var tom = node("Person").named("tom").properties("name", literalOf("Tom Hanks"));
var coActors = anyNode("coActors");
var cocoActors = anyNode("cocoActors");
var strength = count(asterisk()).as("Strength");
var statement = Cypher
.match(
tom.relationshipTo(anyNode("m"), "ACTED_IN").relationshipFrom(coActors, "ACTED_IN"),
coActors.relationshipTo(anyNode("m2"), "ACTED_IN").relationshipFrom(cocoActors, "ACTED_IN")
)
.where(not(tom.relationshipTo(anyNode(), "ACTED_IN").relationshipFrom(cocoActors, "ACTED_IN")))
.and(tom.isNotEqualTo(cocoActors))
.returning(
cocoActors.property("name").as("Recommended"),
strength
).orderBy(strength.asName().descending())
.build();
assertThat(cypherRenderer.render(statement))
.isEqualTo(""
+ "MATCH "
+ "(tom:`Person` {name: 'Tom Hanks'})-[:`ACTED_IN`]-$(m)%-[:`ACTED_IN`]-(coActors), "
+ "(coActors)-[:`ACTED_IN`]-$(m2)%-[:`ACTED_IN`]-(cocoActors) "
+ "WHERE (NOT (tom)-[:`ACTED_IN`]-$()%-[:`ACTED_IN`]-(cocoActors) AND tom <( cocoActors) "
+ "RETURN cocoActors.name AS Recommended, count(*) AS Strength ORDER BY Strength DESC");
Introducing SDN 6 at SpringOne 2020 by @meistermeier and @rotnroll666 28
Current status
• Works with Neo4j 3.4+
• Reactive database access needs 4.0
• Multi-database feature needs Neo4j Enterprise Edition
• Works with Neo4j Aura https://neo4j.com/aura/
• Provides Neo4j support in JHipster https://www.jhipster.tech
Introducing SDN 6 at SpringOne 2020 by @meistermeier and @rotnroll666 29
Current status
• Original version released as SDN/RX in April 2020
• Used already by customers
• Will replace SDN+Neo4j-OGM in Spring Boot 2.4 / Spring Data Release Train
Ockham (2020.0.0)
• SDN+Neo4j-OGM in Spring Boot 2.3 and before still supported and
maintained
• Good choice for new projects
• More effort to migrate existing SDN+Neo4j-OGM code
• Different packages
• More opinionated behavior
Introducing SDN 6 at SpringOne 2020 by @meistermeier and @rotnroll666 30
Links
• Announcement of SDN 6.0
https://bit.ly/welcome_sdn6
• Spring Data Neo4j
https://spring.io/projects/spring-data-neo4j
• Neo4j Cypher-DSL
https://github.com/neo4j-contrib/cypher-dsl
• Neo4j Downloads
https://neo4j.org/downloads
• Neo4j Aura
https://neo4j.org/aura
• Neo4j Community Site
https://community.neo4j.com/
Thank you!

More Related Content

What's hot

Hybrid Apps (Native + Web) via QtWebKit
Hybrid Apps (Native + Web) via QtWebKitHybrid Apps (Native + Web) via QtWebKit
Hybrid Apps (Native + Web) via QtWebKit
Ariya Hidayat
 

What's hot (20)

Implement Service Broker with Spring Boot #cf_tokyo
Implement Service Broker with Spring Boot #cf_tokyoImplement Service Broker with Spring Boot #cf_tokyo
Implement Service Broker with Spring Boot #cf_tokyo
 
Welcome to the Metrics
Welcome to the MetricsWelcome to the Metrics
Welcome to the Metrics
 
Microservices for the Masses with Spring Boot, JHipster, and OAuth - South We...
Microservices for the Masses with Spring Boot, JHipster, and OAuth - South We...Microservices for the Masses with Spring Boot, JHipster, and OAuth - South We...
Microservices for the Masses with Spring Boot, JHipster, and OAuth - South We...
 
Java REST API Comparison: Micronaut, Quarkus, and Spring Boot - jconf.dev 2020
Java REST API Comparison: Micronaut, Quarkus, and Spring Boot - jconf.dev 2020Java REST API Comparison: Micronaut, Quarkus, and Spring Boot - jconf.dev 2020
Java REST API Comparison: Micronaut, Quarkus, and Spring Boot - jconf.dev 2020
 
High Performance Cloud Native APIs Using Apache Geode
High Performance Cloud Native APIs Using Apache Geode High Performance Cloud Native APIs Using Apache Geode
High Performance Cloud Native APIs Using Apache Geode
 
Microservices for the Masses with Spring Boot, JHipster, and OAuth - Utah JUG...
Microservices for the Masses with Spring Boot, JHipster, and OAuth - Utah JUG...Microservices for the Masses with Spring Boot, JHipster, and OAuth - Utah JUG...
Microservices for the Masses with Spring Boot, JHipster, and OAuth - Utah JUG...
 
Spring Boot Loves K8s
Spring Boot Loves K8sSpring Boot Loves K8s
Spring Boot Loves K8s
 
クラウド時代の Spring Framework (aka Spring Framework in Cloud Era)
クラウド時代の Spring Framework (aka Spring Framework in Cloud Era)クラウド時代の Spring Framework (aka Spring Framework in Cloud Era)
クラウド時代の Spring Framework (aka Spring Framework in Cloud Era)
 
Springboot Microservices
Springboot MicroservicesSpringboot Microservices
Springboot Microservices
 
Spring Boot Actuator 2.0 & Micrometer
Spring Boot Actuator 2.0 & MicrometerSpring Boot Actuator 2.0 & Micrometer
Spring Boot Actuator 2.0 & Micrometer
 
Cloud-Native Streaming and Event-Driven Microservices
Cloud-Native Streaming and Event-Driven MicroservicesCloud-Native Streaming and Event-Driven Microservices
Cloud-Native Streaming and Event-Driven Microservices
 
Bootiful Development with Spring Boot and React - Richmond JUG 2018
Bootiful Development with Spring Boot and React - Richmond JUG 2018Bootiful Development with Spring Boot and React - Richmond JUG 2018
Bootiful Development with Spring Boot and React - Richmond JUG 2018
 
Security Patterns for Microservice Architectures - Oktane20
Security Patterns for Microservice Architectures - Oktane20Security Patterns for Microservice Architectures - Oktane20
Security Patterns for Microservice Architectures - Oktane20
 
Hybrid Apps (Native + Web) via QtWebKit
Hybrid Apps (Native + Web) via QtWebKitHybrid Apps (Native + Web) via QtWebKit
Hybrid Apps (Native + Web) via QtWebKit
 
Choosing a Java Web Framework
Choosing a Java Web FrameworkChoosing a Java Web Framework
Choosing a Java Web Framework
 
Full Steam Ahead, R2DBC!
Full Steam Ahead, R2DBC!Full Steam Ahead, R2DBC!
Full Steam Ahead, R2DBC!
 
Os Johnson
Os JohnsonOs Johnson
Os Johnson
 
A Gentle Introduction to Angular Schematics - Devoxx Belgium 2019
A Gentle Introduction to Angular Schematics - Devoxx Belgium 2019A Gentle Introduction to Angular Schematics - Devoxx Belgium 2019
A Gentle Introduction to Angular Schematics - Devoxx Belgium 2019
 
10 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 2020
10 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 202010 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 2020
10 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 2020
 
Going Serverless Using the Spring Framework Ecosystem
Going Serverless Using the Spring Framework EcosystemGoing Serverless Using the Spring Framework Ecosystem
Going Serverless Using the Spring Framework Ecosystem
 

Similar to Spring Up Your Graph

10 ways to make your code rock
10 ways to make your code rock10 ways to make your code rock
10 ways to make your code rock
martincronje
 
Graphs & Neo4j - Past Present Future
Graphs & Neo4j - Past Present FutureGraphs & Neo4j - Past Present Future
Graphs & Neo4j - Past Present Future
jexp
 

Similar to Spring Up Your Graph (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
 
Economies of Scaling Software
Economies of Scaling SoftwareEconomies of Scaling Software
Economies of Scaling Software
 
10 ways to make your code rock
10 ways to make your code rock10 ways to make your code rock
10 ways to make your code rock
 
Graphs & Neo4j - Past Present Future
Graphs & Neo4j - Past Present FutureGraphs & Neo4j - Past Present Future
Graphs & Neo4j - Past Present Future
 
Asynchronous single page applications without a line of HTML or Javascript, o...
Asynchronous single page applications without a line of HTML or Javascript, o...Asynchronous single page applications without a line of HTML or Javascript, o...
Asynchronous single page applications without a line of HTML or Javascript, o...
 
Spring.io
Spring.ioSpring.io
Spring.io
 
Leveraging Neo4j With Apache Spark
Leveraging Neo4j With Apache SparkLeveraging Neo4j With Apache Spark
Leveraging Neo4j With Apache Spark
 
MySQL Tech Café #8: MySQL 8.0 for Python Developers
MySQL Tech Café #8: MySQL 8.0 for Python DevelopersMySQL Tech Café #8: MySQL 8.0 for Python Developers
MySQL Tech Café #8: MySQL 8.0 for Python Developers
 
NoSQL Endgame - Java2Days 2020 Virtual
NoSQL Endgame - Java2Days 2020 VirtualNoSQL Endgame - Java2Days 2020 Virtual
NoSQL Endgame - Java2Days 2020 Virtual
 
Agile Data Science 2.0
Agile Data Science 2.0Agile Data Science 2.0
Agile Data Science 2.0
 
Agile Data Science
Agile Data ScienceAgile Data Science
Agile Data Science
 
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)
 
Introduction to MySQL Document Store
Introduction to MySQL Document StoreIntroduction to MySQL Document Store
Introduction to MySQL Document Store
 
From Legacy to Hexagonal (An Unexpected Android Journey)
From Legacy to Hexagonal (An Unexpected Android Journey)From Legacy to Hexagonal (An Unexpected Android Journey)
From Legacy to Hexagonal (An Unexpected Android Journey)
 
GraphConnect Europe 2016 - Opening Keynote, Emil Eifrem
GraphConnect Europe 2016 - Opening Keynote, Emil EifremGraphConnect Europe 2016 - Opening Keynote, Emil Eifrem
GraphConnect Europe 2016 - Opening Keynote, Emil Eifrem
 
Cassandra drivers and libraries
Cassandra drivers and librariesCassandra drivers and libraries
Cassandra drivers and libraries
 
EclipseCon 2021 NoSQL Endgame
EclipseCon 2021 NoSQL EndgameEclipseCon 2021 NoSQL Endgame
EclipseCon 2021 NoSQL Endgame
 
Multiplatform Spark solution for Graph datasources by Javier Dominguez
Multiplatform Spark solution for Graph datasources by Javier DominguezMultiplatform Spark solution for Graph datasources by Javier Dominguez
Multiplatform Spark solution for Graph datasources by Javier Dominguez
 
NoSQL Endgame LWJUG 2021
NoSQL Endgame LWJUG 2021NoSQL Endgame LWJUG 2021
NoSQL Endgame LWJUG 2021
 
Oracle Open World 2018 / Code One : MySQL 8.0 Document Store
Oracle Open World 2018 /  Code One : MySQL 8.0 Document StoreOracle Open World 2018 /  Code One : MySQL 8.0 Document Store
Oracle Open World 2018 / Code One : MySQL 8.0 Document Store
 

More from VMware Tanzu

More from VMware Tanzu (20)

What AI Means For Your Product Strategy And What To Do About It
What AI Means For Your Product Strategy And What To Do About ItWhat AI Means For Your Product Strategy And What To Do About It
What AI Means For Your Product Strategy And What To Do About It
 
Make the Right Thing the Obvious Thing at Cardinal Health 2023
Make the Right Thing the Obvious Thing at Cardinal Health 2023Make the Right Thing the Obvious Thing at Cardinal Health 2023
Make the Right Thing the Obvious Thing at Cardinal Health 2023
 
Enhancing DevEx and Simplifying Operations at Scale
Enhancing DevEx and Simplifying Operations at ScaleEnhancing DevEx and Simplifying Operations at Scale
Enhancing DevEx and Simplifying Operations at Scale
 
Spring Update | July 2023
Spring Update | July 2023Spring Update | July 2023
Spring Update | July 2023
 
Platforms, Platform Engineering, & Platform as a Product
Platforms, Platform Engineering, & Platform as a ProductPlatforms, Platform Engineering, & Platform as a Product
Platforms, Platform Engineering, & Platform as a Product
 
Building Cloud Ready Apps
Building Cloud Ready AppsBuilding Cloud Ready Apps
Building Cloud Ready Apps
 
Spring Boot 3 And Beyond
Spring Boot 3 And BeyondSpring Boot 3 And Beyond
Spring Boot 3 And Beyond
 
Spring Cloud Gateway - SpringOne Tour 2023 Charles Schwab.pdf
Spring Cloud Gateway - SpringOne Tour 2023 Charles Schwab.pdfSpring Cloud Gateway - SpringOne Tour 2023 Charles Schwab.pdf
Spring Cloud Gateway - SpringOne Tour 2023 Charles Schwab.pdf
 
Simplify and Scale Enterprise Apps in the Cloud | Boston 2023
Simplify and Scale Enterprise Apps in the Cloud | Boston 2023Simplify and Scale Enterprise Apps in the Cloud | Boston 2023
Simplify and Scale Enterprise Apps in the Cloud | Boston 2023
 
Simplify and Scale Enterprise Apps in the Cloud | Seattle 2023
Simplify and Scale Enterprise Apps in the Cloud | Seattle 2023Simplify and Scale Enterprise Apps in the Cloud | Seattle 2023
Simplify and Scale Enterprise Apps in the Cloud | Seattle 2023
 
tanzu_developer_connect.pptx
tanzu_developer_connect.pptxtanzu_developer_connect.pptx
tanzu_developer_connect.pptx
 
Tanzu Virtual Developer Connect Workshop - French
Tanzu Virtual Developer Connect Workshop - FrenchTanzu Virtual Developer Connect Workshop - French
Tanzu Virtual Developer Connect Workshop - French
 
Tanzu Developer Connect Workshop - English
Tanzu Developer Connect Workshop - EnglishTanzu Developer Connect Workshop - English
Tanzu Developer Connect Workshop - English
 
Virtual Developer Connect Workshop - English
Virtual Developer Connect Workshop - EnglishVirtual Developer Connect Workshop - English
Virtual Developer Connect Workshop - English
 
Tanzu Developer Connect - French
Tanzu Developer Connect - FrenchTanzu Developer Connect - French
Tanzu Developer Connect - French
 
Simplify and Scale Enterprise Apps in the Cloud | Dallas 2023
Simplify and Scale Enterprise Apps in the Cloud | Dallas 2023Simplify and Scale Enterprise Apps in the Cloud | Dallas 2023
Simplify and Scale Enterprise Apps in the Cloud | Dallas 2023
 
SpringOne Tour: Deliver 15-Factor Applications on Kubernetes with Spring Boot
SpringOne Tour: Deliver 15-Factor Applications on Kubernetes with Spring BootSpringOne Tour: Deliver 15-Factor Applications on Kubernetes with Spring Boot
SpringOne Tour: Deliver 15-Factor Applications on Kubernetes with Spring Boot
 
SpringOne Tour: The Influential Software Engineer
SpringOne Tour: The Influential Software EngineerSpringOne Tour: The Influential Software Engineer
SpringOne Tour: The Influential Software Engineer
 
SpringOne Tour: Domain-Driven Design: Theory vs Practice
SpringOne Tour: Domain-Driven Design: Theory vs PracticeSpringOne Tour: Domain-Driven Design: Theory vs Practice
SpringOne Tour: Domain-Driven Design: Theory vs Practice
 
SpringOne Tour: Spring Recipes: A Collection of Common-Sense Solutions
SpringOne Tour: Spring Recipes: A Collection of Common-Sense SolutionsSpringOne Tour: Spring Recipes: A Collection of Common-Sense Solutions
SpringOne Tour: Spring Recipes: A Collection of Common-Sense Solutions
 

Recently uploaded

The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 

Recently uploaded (20)

Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 

Spring Up Your Graph

  • 1. Spice up Your Graph Gerrit Meier and Michael Simons introducing the all new Spring Data Neo4j (SDN 6) SpringOne 2020 Spring
  • 2. Introducing SDN 6 at SpringOne 2020 by @meistermeier and @rotnroll666 2
  • 3. Introducing SDN 6 at SpringOne 2020 by @meistermeier and @rotnroll666 4 Label Type
  • 4. Introducing SDN 6 at SpringOne 2020 by @meistermeier and @rotnroll666 5 Person KNOWS { name: "Mr. X" dob: 26.02.1982 } { met: "Spring One" contact: 03.09.2020 }
  • 5. Introducing SDN 6 at SpringOne 2020 by @meistermeier and @rotnroll666 6 Person KNOWS Person Topic INTERESTED_IN INTERESTED_IN { term: "Spring Data" description: " … " } Graph Databases
  • 6. Introducing SDN 6 at SpringOne 2020 by @meistermeier and @rotnroll666 7 Spring Data Neo4j Team @meistermeier @rotnroll666
  • 7. What would you do if you could create yet another object mapper from scratch?
  • 8. What would you do if you could create yet another object mapper from scratch? Why
  • 9. Introducing SDN 6 at SpringOne 2020 by @meistermeier and @rotnroll666 9 Current Spring Data Neoj4 + Neo4j-OGM • start.spring.io gives you SDN and Neo4j-OGM • 3 different modes available (Embedded, HTTP and native) • Makes usage of Cypher harder than necessary • Custom queries are possible but go all through the Neo4j-OGM abstraction • Some building parts stack vertically, some horizontally ➡ Confusing options for beginners
  • 11. Introducing SDN 6 at SpringOne 2020 by @meistermeier and @rotnroll666 11 What do we want? • A composable stack • Nicely integrated in Spring Boot • Access at all abstraction levels • Raw queries (outside application level transactions) • Raw queries (inside application level transactions) • Plus ad-hoc mapping • Mapping • Repository abstraction • Reactive (and imperative) database access
  • 12. Introducing SDN 6 at SpringOne 2020 by @meistermeier and @rotnroll666 • Java Driver • Direct usage • Simple Client • RowMapper-like • Neo4jTemplate • Entity-Metadata aware • Repositories • DDD way of accessing your data Multiple, ordered levels of Abstraction
  • 13. Introducing SDN 6 at SpringOne 2020 by @meistermeier and @rotnroll666 13 Spring Data Repositories Neo4j Template Neo4j Client Neo4j Java Driver spring-boot-starter-data-neo4j spring-boot-autoconfigure SDN 6 provides configures A composable stack
  • 14. Introducing SDN 6 at SpringOne 2020 by @meistermeier and @rotnroll666 • Imperative and reactive on par • New: Reactive transactions Reactive support
  • 15. Introducing SDN 6 at SpringOne 2020 by @meistermeier and @rotnroll666 • Bolt protocol • Driver type system 100%-based on Neo4j Java Driver
  • 16. Introducing SDN 6 at SpringOne 2020 by @meistermeier and @rotnroll666 18 @Autowired org.neo4j.driver.Driver @RestController public class MoviesController { private final Driver driver; public MoviesController(Driver driver) { this.driver = driver; } @GetMapping(path = "/movies", produces = MediaType.TEXT_EVENT_STREAM_VALUE) public Flux<String> getMovieTitles() { /# Using an implicit, driver managed transaction return Flux.usingWhen( Mono.fromSupplier(driver:%rxSession), s -' Flux.from(s.run("MATCH (m:Movie) RETURN m ORDER BY m.name ASC").records()), RxSession:%close ).map(r -' r.get("m").asNode().get("title").asString()); } } Based on open standards: Reactive Streams. Can be used with RxJava2, too.
  • 17. Introducing SDN 6 at SpringOne 2020 by @meistermeier and @rotnroll666 @Service public class MovieService { private final ReactiveNeo4jClient client; public MovieService(ReactiveNeo4jClient client) { this.client = client; } /# Fully integrated with Springs declarative /# or explicit transactions (via TransactionalOperator or TransactionTemplate) @Transactional public Flux<String> getMovieTitles() { return client.query("MATCH (m:Movie) RETURN m ORDER BY m.name ASC") .fetchAs(String.class) .mappedBy((typeSystem, record) -' record.get("m").asNode().get("title").asString()) .all(); } } 19 @Autowired org.springframework.data.neo4j.core.ReactiveNeo4jClient
  • 18. Introducing SDN 6 at SpringOne 2020 by @meistermeier and @rotnroll666 20 @Autowired org.springframework.data.neo4j.core.ReactiveNeo4jTemplate @Service public class MovieService { private final ReactiveNeo4jTemplate template; public MovieService(ReactiveNeo4jTemplate template) { this.template = template; } @Transactional public Flux<String> getMovieTitles() { /# Overload with custom query available return template.findAll(MovieEntity.class) .map(MovieEntity:%getTitle); } } @Node("Movie") class MovieEntity { private @Id final String title; private @Property("tagline") final String description; @Relationship(type = "ACTED_IN", direction = INCOMING) private final Map<PersonEntity, Roles> actorsAndRoles; /# Full immutable class, works also with @Data, /# Kotlin and JDK 14 records public MovieEntity(String title, String description, Map<PersonEntity, Roles> actorsAndRoles ) { this.title = title; this.description = description; this.actorsAndRoles = actorsAndRoles; } }
  • 19. Introducing SDN 6 at SpringOne 2020 by @meistermeier and @rotnroll666 public interface MovieRepository extends ReactiveNeo4jRepository<MovieEntity, String> {} @Service public class MovieService { private final MovieRepository repository; public MovieService(MovieRepository repository) { this.repository = repository; } @Transactional public Flux<String> getMovieTitles() { /# Custom query via @Query on a method /# For simple cases, use derived query methods /# repository.findAllByOrderByTitle return repository.findAll() .map(MovieEntity:%getTitle); /# For the first time with Spring Data and Neo4j, query by Example /# return repository.findAll(Example.of(new MovieEntity("The Matrix", null))); } } 21 @Autowired org.springframework.data.neo4j.core.ReactiveNeo4jRepository
  • 20. Introducing SDN 6 at SpringOne 2020 by @meistermeier and @rotnroll666 • Instances via • (persistent) constructor • wither • setter • No reflection violating the contract Immutable Mapping
  • 21. Introducing SDN 6 at SpringOne 2020 by @meistermeier and @rotnroll666 • Neo4j Driver Java auto-config • Properties where they belong • Updated SDN starter • Getting you up to speed in a blink • Health Checks • Based on the Java Driver Spring Boot integration
  • 22. Introducing SDN 6 at SpringOne 2020 by @meistermeier and @rotnroll666 @ConfigurationProperties(prefix = "spring.neo4j") public class Neo4jProperties { public static class Authentication { /** The login of the user connecting to the database.** private String username; /** The password of the user connecting to the database. ** private String password; /** The realm to connect to.** private String realm; } /** The uri this driver should connect to. The driver supports bolt or neo4j as schemes.** private URI uri; /** The authentication the driver is supposed to use. Maybe null. ** private Authentication authentication = new Authentication(); } 24 Access to all configuration settings Consistent across frameworks!
  • 23. Introducing SDN 6 at SpringOne 2020 by @meistermeier and @rotnroll666 Less Surprises
  • 24. Introducing SDN 6 at SpringOne 2020 by @meistermeier and @rotnroll666 Cypher DSL • Zero dependency library • Compile-time checked query construction • Re-usable instances
  • 25. Introducing SDN 6 at SpringOne 2020 by @meistermeier and @rotnroll666 27 var tom = node("Person").named("tom").properties("name", literalOf("Tom Hanks")); var coActors = anyNode("coActors"); var cocoActors = anyNode("cocoActors"); var strength = count(asterisk()).as("Strength"); var statement = Cypher .match( tom.relationshipTo(anyNode("m"), "ACTED_IN").relationshipFrom(coActors, "ACTED_IN"), coActors.relationshipTo(anyNode("m2"), "ACTED_IN").relationshipFrom(cocoActors, "ACTED_IN") ) .where(not(tom.relationshipTo(anyNode(), "ACTED_IN").relationshipFrom(cocoActors, "ACTED_IN"))) .and(tom.isNotEqualTo(cocoActors)) .returning( cocoActors.property("name").as("Recommended"), strength ).orderBy(strength.asName().descending()) .build(); assertThat(cypherRenderer.render(statement)) .isEqualTo("" + "MATCH " + "(tom:`Person` {name: 'Tom Hanks'})-[:`ACTED_IN`]-$(m)%-[:`ACTED_IN`]-(coActors), " + "(coActors)-[:`ACTED_IN`]-$(m2)%-[:`ACTED_IN`]-(cocoActors) " + "WHERE (NOT (tom)-[:`ACTED_IN`]-$()%-[:`ACTED_IN`]-(cocoActors) AND tom <( cocoActors) " + "RETURN cocoActors.name AS Recommended, count(*) AS Strength ORDER BY Strength DESC");
  • 26. Introducing SDN 6 at SpringOne 2020 by @meistermeier and @rotnroll666 28 Current status • Works with Neo4j 3.4+ • Reactive database access needs 4.0 • Multi-database feature needs Neo4j Enterprise Edition • Works with Neo4j Aura https://neo4j.com/aura/ • Provides Neo4j support in JHipster https://www.jhipster.tech
  • 27. Introducing SDN 6 at SpringOne 2020 by @meistermeier and @rotnroll666 29 Current status • Original version released as SDN/RX in April 2020 • Used already by customers • Will replace SDN+Neo4j-OGM in Spring Boot 2.4 / Spring Data Release Train Ockham (2020.0.0) • SDN+Neo4j-OGM in Spring Boot 2.3 and before still supported and maintained • Good choice for new projects • More effort to migrate existing SDN+Neo4j-OGM code • Different packages • More opinionated behavior
  • 28. Introducing SDN 6 at SpringOne 2020 by @meistermeier and @rotnroll666 30 Links • Announcement of SDN 6.0 https://bit.ly/welcome_sdn6 • Spring Data Neo4j https://spring.io/projects/spring-data-neo4j • Neo4j Cypher-DSL https://github.com/neo4j-contrib/cypher-dsl • Neo4j Downloads https://neo4j.org/downloads • Neo4j Aura https://neo4j.org/aura • Neo4j Community Site https://community.neo4j.com/