SlideShare ist ein Scribd-Unternehmen logo
1 von 27
Downloaden Sie, um offline zu lesen
GraphAware®
Build Spring Data
Neo4j 4 Applications
like a Superhero
graphaware.com

@graph_aware, @luannem
Luanne Misquitta
Most active Spring project

Convenient data access to (No)SQL databases

Consistent API’s

Mapping POJOs, Template, Repositories

Neo4j, JPA, MongoDB, Redis, CouchBase & more

Spring Data
GraphAware®
Focus on performance

Based on a pure Java OGM [Neo4j-OGM]

3 Drivers available to connect to Neo4j

HTTP

Embedded

Bolt

Spring Data Neo4j 4.1
GraphAware®
Object Graph Mapping from any Java or JVM-based application

“Vampire” metadata scanning (no reflection!)

“Smart” object mapping

Mapping contexts tied to Session lifetimes

Application

HTTP session/request etc.

Support for default and bespoke type conversions

Repositories, Neo4jTemplate [SDN]

Custom Queries, Derived Finders [SDN]

Transactional Support

Features
GraphAware®
Persistence horizon (depth) indicates how many relationships
should be traversed in the graph when loading or saving data

Default loading depth is 1

Default persistence depth is -1
Variable Depth Persistence
GraphAware®
It’s a bird, it’s a plane, 

it’s a superhero graph!
Node Entities - Character
GraphAware®
@NodeEntity(label = "Character")
public class Character {
@GraphId Long graphId;
…
private Long id;
private String name;
private String alias;
private String realName;
Node Entities - Relationships
GraphAware®
public class Character {
…
@Relationship(type = "ALLY_OF", direction = Relationship.UNDIRECTED)
@Relationship(type = "ENEMY_OF", direction = Relationship.UNDIRECTED)
@Relationship(type = "MEMBER_OF")
@Relationship(type = "STARS", direction = Relationship.INCOMING)
Set<Character> allies = new HashSet<>();
Set<Character> enemies = new HashSet<>();
Set<Team> teams = new HashSet<>();
Set<Role> roles = new HashSet<>();
Set<Game> gamesFeaturedIn = new HashSet<>();
@Relationship(type = "FEATURED_IN")
@Relationship(type = "FEATURED_IN")
Set<Comic> comicsFeaturedIn = new HashSet<>();
Node Entities - Hierarchy
GraphAware®
public class Villain extends Character{
…
}
public class Hero extends Character {
…

}
@NodeEntity(label = "Hero")
@NodeEntity(label = "Villain")
Node Entities - Team
GraphAware®
@NodeEntity(label = "Team")
public class Team {
@GraphId private Long graphId;
private Long id;
private String name;
private String operationsBase;
@Relationship(type = "MEMBER_OF",
direction = "INCOMING")
private Set<Character> members = new HashSet<>();
public Team() {
}
Node Entities - Comic
GraphAware®
@NodeEntity(label = "Comic")
private Long id;
private String title;
private String author;
private String artist;
private boolean available;
private Binding binding;
@DateLong
private Date onSaleDate;
@Relationship(type = "FEATURED_IN", direction = Relationship.INCOMING)
private Set<Character> characters = new HashSet<>();
public enum Binding {
SOFT,
LEATHER,
CLOTH,
HARD
}
public class Comic {
@GraphId private Long graphId;
Node Entities - Game
GraphAware®
@NodeEntity(label = "Game")
public class Game {
@Graphid private Long graphId;
private Long id;
private String title;
private int year;
private String publisher;
private Rating rating;
private Set<Platform> platforms;
@Relationship(type = "FEATURED_IN",
direction = Relationship.INCOMING)
private Set<Character> characters = new HashSet<>();
public enum Platform {
PC,
WII,
XBOX_360,
PLAYSTATION_3
}
Node Entities
GraphAware®
@Convert(UrlConverter.class)
private URL imdbUrl;
@Relationship(type = "STARS")
private Set<Role> stars;
public class UrlConverter implements
AttributeConverter<URL, String> {
@Override
public String toGraphProperty(URL value) {
return value == null? null : value.toString();
}
@Override
public URL toEntityAttribute(String value) {
try {
return new URL(value);
} catch (MalformedURLException e) {
e.printStackTrace();
}
return null;
}

}
@NodeEntity(label = "Movie")
public class Movie {
@GraphId private Long graphId;
private Long id;
private String title;
private int year;
private Rating rating;
Relationship Entities
GraphAware®
@RelationshipEntity(type = "STARS")
public class Role {
private Long id;
@StartNode private Movie movie;
@EndNode private Character character;
private String actor;
Repositories
GraphAware®
public interface CharacterRepository<T extends Character> extends GraphRepository<T> {
List<T> findByNameLike(String keyword);
@Query(" MATCH (c:Character) WHERE ID(c)={characterId} " +
"OPTIONAL MATCH (c)-[:ALLY_OF|ENEMY_OF]-(other) " +
"WITH c, collect(other) as others " +
"OPTIONAL MATCH (c)-[:MEMBER_OF|FEATURED_IN]->
()<-[:MEMBER_OF|FEATURED_IN]-(teamMember) " +
"WITH c, others + collect(teamMember) as othersWithTeam " +
"OPTIONAL MATCH (c)<-[:STARS]-()-[:STARS]->(actors) " +
"WITH othersWithTeam + collect(actors) as allOthers " +
"UNWIND allOthers as related " +
"WITH count(*) as count, related " +
"RETURN related ORDER BY count DESC")
List<Character> findRelatedCharacters(@Param("characterId") Long id);
Repositories
GraphAware®
public interface HeroRepository extends
CharacterRepository<Hero> {
}
public interface VillainRepository extends
CharacterRepository<Villain>{
}
Services
GraphAware®
@Service
public class CharacterService {
@Autowired CharacterRepository<Character> characterRepository;
@Autowired HeroRepository heroRepository;
@Autowired VillainRepository villainRepository;
public List<CharacterSummary> searchHeroesByKeyword(String keyword) {
return summarizeCharacter(heroRepository.findByNameLike(getKeywordParam(keyword))
}
public List<Character> findRelatedCharacters(Long id) {
return characterRepository.findRelatedCharacters(id);
}
public Character getById(Long id) {
return characterRepository.findById(id);
}
…
}
Controller
GraphAware®
@RestController
@RequestMapping("/api/")
public class CharacterController {
@Autowired CharacterService characterService;
@RequestMapping(value = "characters/{id}", method = RequestMethod.GET)
public Character getCharacterById(@PathVariable("id") Long id) {
return characterService.getById(id);
}
@RequestMapping(value = "characters/{id}/related", method = RequestMethod.GET)
public List<Character> getRelatedCharacters(@PathVariable("id") Long id) {
return characterService.findRelatedCharacters(id);
}
SDN 4.1 / Neo4j OGM Driver
Configuration
GraphAware®
driver=org.neo4j.ogm.drivers.http.driver.HttpDriver
URI=http://neo4j:neo@localhost:7474
Auto configure with ogm.properties
Java Configuration
Components.configuration()
.driverConfiguration()
.setDriverClassName("org.neo4j.ogm.drivers.http.driver.HttpDriver")
.setURI("http://user:password@localhost:7474")
SDN 4.1 Neo4j Configuration
GraphAware®
@Configuration
@ComponentScan("com.graphaware.superhero")
@EnableAutoConfiguration
@EnableTransactionManagement
@EnableNeo4jRepositories("com.graphaware.superhero.repository")
public class Application extends Neo4jConfiguration {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
…
SDN 4.1 Neo4j Configuration
GraphAware®
…
public class Application extends Neo4jConfiguration {
@Override
@Bean
public SessionFactory getSessionFactory() {
return new SessionFactory("com.graphaware.superhero.domain");
}
@Override
@Bean
@Scope(value = "session", proxyMode = ScopedProxyMode.TARGET_CLASS)
public Session getSession() throws Exception {
return super.getSession();
}
Up, up and away!
GraphAware®
mvn clean spring-boot:run
Documentation: http://docs.spring.io/spring-data/neo4j/docs/
current/reference/html/

Code: https://github.com/spring-projects/spring-data-neo4j

Sample Applications: http://github.com/neo4j-examples?
query=sdn4
Where to find stuff
GraphAware®
Where to find us
GraphAware®
Luanne Misquitta
Adam George
Michal “Batman” Bachman
Vince Bickers
Getting Help
StackOverflow (spring-data-neo4j-4, neo4j-ogm)

Slack: neo4j-users (neo4j-sdn)

Email the team: spring-data-neo4j@neotechnology.com

Raise issues: https://jira.spring.io/browse/DATAGRAPH

Twitter: Follow @graph_aware for pro tips

Blog: http://graphaware.com/blog
You’re a Graph Hero!
www.graphaware.com

@graph_aware
Thank you
GraphAware®

Weitere ähnliche Inhalte

Was ist angesagt?

(Big) Data Serialization with Avro and Protobuf
(Big) Data Serialization with Avro and Protobuf(Big) Data Serialization with Avro and Protobuf
(Big) Data Serialization with Avro and Protobuf
Guido Schmutz
 
The openCypher Project - An Open Graph Query Language
The openCypher Project - An Open Graph Query LanguageThe openCypher Project - An Open Graph Query Language
The openCypher Project - An Open Graph Query Language
Neo4j
 
OrientDB the graph database
OrientDB the graph databaseOrientDB the graph database
OrientDB the graph database
Artem Orobets
 

Was ist angesagt? (20)

Benefits of Using MongoDB Over RDBMS (At An Evening with MongoDB Minneapolis ...
Benefits of Using MongoDB Over RDBMS (At An Evening with MongoDB Minneapolis ...Benefits of Using MongoDB Over RDBMS (At An Evening with MongoDB Minneapolis ...
Benefits of Using MongoDB Over RDBMS (At An Evening with MongoDB Minneapolis ...
 
(Big) Data Serialization with Avro and Protobuf
(Big) Data Serialization with Avro and Protobuf(Big) Data Serialization with Avro and Protobuf
(Big) Data Serialization with Avro and Protobuf
 
The openCypher Project - An Open Graph Query Language
The openCypher Project - An Open Graph Query LanguageThe openCypher Project - An Open Graph Query Language
The openCypher Project - An Open Graph Query Language
 
Datastax enterprise presentation
Datastax enterprise presentationDatastax enterprise presentation
Datastax enterprise presentation
 
Extending Cassandra with Doradus OLAP for High Performance Analytics
Extending Cassandra with Doradus OLAP for High Performance AnalyticsExtending Cassandra with Doradus OLAP for High Performance Analytics
Extending Cassandra with Doradus OLAP for High Performance Analytics
 
OrientDB the graph database
OrientDB the graph databaseOrientDB the graph database
OrientDB the graph database
 
MongoDB crud
MongoDB crudMongoDB crud
MongoDB crud
 
Webinar: Index Tuning and Evaluation
Webinar: Index Tuning and EvaluationWebinar: Index Tuning and Evaluation
Webinar: Index Tuning and Evaluation
 
JS Fest 2019/Autumn. Maciej Treder. Angular Schematics - Develop for developers
JS Fest 2019/Autumn. Maciej Treder. Angular Schematics - Develop for developersJS Fest 2019/Autumn. Maciej Treder. Angular Schematics - Develop for developers
JS Fest 2019/Autumn. Maciej Treder. Angular Schematics - Develop for developers
 
2011 Mongo FR - Indexing in MongoDB
2011 Mongo FR - Indexing in MongoDB2011 Mongo FR - Indexing in MongoDB
2011 Mongo FR - Indexing in MongoDB
 
Cubes - Lightweight Python OLAP (EuroPython 2012 talk)
Cubes - Lightweight Python OLAP (EuroPython 2012 talk)Cubes - Lightweight Python OLAP (EuroPython 2012 talk)
Cubes - Lightweight Python OLAP (EuroPython 2012 talk)
 
Introducing DataFrames in Spark for Large Scale Data Science
Introducing DataFrames in Spark for Large Scale Data ScienceIntroducing DataFrames in Spark for Large Scale Data Science
Introducing DataFrames in Spark for Large Scale Data Science
 
Aggregation Framework in MongoDB Overview Part-1
Aggregation Framework in MongoDB Overview Part-1Aggregation Framework in MongoDB Overview Part-1
Aggregation Framework in MongoDB Overview Part-1
 
Introduction to solr
Introduction to solrIntroduction to solr
Introduction to solr
 
OrientDB vs Neo4j - and an introduction to NoSQL databases
OrientDB vs Neo4j - and an introduction to NoSQL databasesOrientDB vs Neo4j - and an introduction to NoSQL databases
OrientDB vs Neo4j - and an introduction to NoSQL databases
 
Aggregation Framework MongoDB Days Munich
Aggregation Framework MongoDB Days MunichAggregation Framework MongoDB Days Munich
Aggregation Framework MongoDB Days Munich
 
Cassandra 3 new features 2016
Cassandra 3 new features 2016Cassandra 3 new features 2016
Cassandra 3 new features 2016
 
Webinar: What's New in Solr 6
Webinar: What's New in Solr 6Webinar: What's New in Solr 6
Webinar: What's New in Solr 6
 
Green dao
Green daoGreen dao
Green dao
 
Datastax day 2016 : Cassandra data modeling basics
Datastax day 2016 : Cassandra data modeling basicsDatastax day 2016 : Cassandra data modeling basics
Datastax day 2016 : Cassandra data modeling basics
 

Andere mochten auch

GraphConnect Europe 2016 - Navigating All the Knowledge - James Weaver
GraphConnect Europe 2016 - Navigating All the Knowledge - James WeaverGraphConnect Europe 2016 - Navigating All the Knowledge - James Weaver
GraphConnect Europe 2016 - Navigating All the Knowledge - James Weaver
Neo4j
 
GraphConnect Europe 2016 - Pushing the Evolution of Software Analytics with G...
GraphConnect Europe 2016 - Pushing the Evolution of Software Analytics with G...GraphConnect Europe 2016 - Pushing the Evolution of Software Analytics with G...
GraphConnect Europe 2016 - Pushing the Evolution of Software Analytics with G...
Neo4j
 
GraphConnect Europe 2016 - Creating the Best Teams Ever with Collaborative Fi...
GraphConnect Europe 2016 - Creating the Best Teams Ever with Collaborative Fi...GraphConnect Europe 2016 - Creating the Best Teams Ever with Collaborative Fi...
GraphConnect Europe 2016 - Creating the Best Teams Ever with Collaborative Fi...
Neo4j
 
GraphConnect Europe 2016 - Inside the Spider’s Web: Dependency Management wit...
GraphConnect Europe 2016 - Inside the Spider’s Web: Dependency Management wit...GraphConnect Europe 2016 - Inside the Spider’s Web: Dependency Management wit...
GraphConnect Europe 2016 - Inside the Spider’s Web: Dependency Management wit...
Neo4j
 
GraphConnect Europe 2016 - Faster Lap Times with Neo4j - Srinivas Suravarapu
GraphConnect Europe 2016 - Faster Lap Times with Neo4j - Srinivas SuravarapuGraphConnect Europe 2016 - Faster Lap Times with Neo4j - Srinivas Suravarapu
GraphConnect Europe 2016 - Faster Lap Times with Neo4j - Srinivas Suravarapu
Neo4j
 
GraphConnect Europe 2016 - Governing Multichannel Services with Graphs - Albe...
GraphConnect Europe 2016 - Governing Multichannel Services with Graphs - Albe...GraphConnect Europe 2016 - Governing Multichannel Services with Graphs - Albe...
GraphConnect Europe 2016 - Governing Multichannel Services with Graphs - Albe...
Neo4j
 
GraphConnect Europe 2016 - Enterprise Data Integration with a new JDBC Driver...
GraphConnect Europe 2016 - Enterprise Data Integration with a new JDBC Driver...GraphConnect Europe 2016 - Enterprise Data Integration with a new JDBC Driver...
GraphConnect Europe 2016 - Enterprise Data Integration with a new JDBC Driver...
Neo4j
 
GraphConnect Europe 2016 - Digitalization and Optimizing Business Performance...
GraphConnect Europe 2016 - Digitalization and Optimizing Business Performance...GraphConnect Europe 2016 - Digitalization and Optimizing Business Performance...
GraphConnect Europe 2016 - Digitalization and Optimizing Business Performance...
Neo4j
 
GraphConnect Europe 2016 - Securely Deploying Neo4j into AWS - Benjamin Nussbaum
GraphConnect Europe 2016 - Securely Deploying Neo4j into AWS - Benjamin NussbaumGraphConnect Europe 2016 - Securely Deploying Neo4j into AWS - Benjamin Nussbaum
GraphConnect Europe 2016 - Securely Deploying Neo4j into AWS - Benjamin Nussbaum
Neo4j
 
GraphConnect Europe 2016 - Building Consumer Trust through Transparency, Comp...
GraphConnect Europe 2016 - Building Consumer Trust through Transparency, Comp...GraphConnect Europe 2016 - Building Consumer Trust through Transparency, Comp...
GraphConnect Europe 2016 - Building Consumer Trust through Transparency, Comp...
Neo4j
 
GraphConnect Europe 2016 - Building a Repository of Biomedical Ontologies wit...
GraphConnect Europe 2016 - Building a Repository of Biomedical Ontologies wit...GraphConnect Europe 2016 - Building a Repository of Biomedical Ontologies wit...
GraphConnect Europe 2016 - Building a Repository of Biomedical Ontologies wit...
Neo4j
 

Andere mochten auch (20)

GraphConnect Europe 2016 - Who Cares What Beyonce Ate for Lunch? - Alicia Powers
GraphConnect Europe 2016 - Who Cares What Beyonce Ate for Lunch? - Alicia PowersGraphConnect Europe 2016 - Who Cares What Beyonce Ate for Lunch? - Alicia Powers
GraphConnect Europe 2016 - Who Cares What Beyonce Ate for Lunch? - Alicia Powers
 
GraphConnect Europe 2016 - Navigating All the Knowledge - James Weaver
GraphConnect Europe 2016 - Navigating All the Knowledge - James WeaverGraphConnect Europe 2016 - Navigating All the Knowledge - James Weaver
GraphConnect Europe 2016 - Navigating All the Knowledge - James Weaver
 
GraphConnect Europe 2016 - Pushing the Evolution of Software Analytics with G...
GraphConnect Europe 2016 - Pushing the Evolution of Software Analytics with G...GraphConnect Europe 2016 - Pushing the Evolution of Software Analytics with G...
GraphConnect Europe 2016 - Pushing the Evolution of Software Analytics with G...
 
GraphConnect Europe 2016 - Moving Graphs to Production at Scale - Ian Robinson
GraphConnect Europe 2016 - Moving Graphs to Production at Scale - Ian RobinsonGraphConnect Europe 2016 - Moving Graphs to Production at Scale - Ian Robinson
GraphConnect Europe 2016 - Moving Graphs to Production at Scale - Ian Robinson
 
GraphConnect Europe 2016 - Tuning Your Cypher - Petra Selmer, Mark Needham
GraphConnect Europe 2016 - Tuning Your Cypher - Petra Selmer, Mark NeedhamGraphConnect Europe 2016 - Tuning Your Cypher - Petra Selmer, Mark Needham
GraphConnect Europe 2016 - Tuning Your Cypher - Petra Selmer, Mark Needham
 
GraphConnect Europe 2016 - Creating the Best Teams Ever with Collaborative Fi...
GraphConnect Europe 2016 - Creating the Best Teams Ever with Collaborative Fi...GraphConnect Europe 2016 - Creating the Best Teams Ever with Collaborative Fi...
GraphConnect Europe 2016 - Creating the Best Teams Ever with Collaborative Fi...
 
GraphConnect Europe 2016 - Inside the Spider’s Web: Dependency Management wit...
GraphConnect Europe 2016 - Inside the Spider’s Web: Dependency Management wit...GraphConnect Europe 2016 - Inside the Spider’s Web: Dependency Management wit...
GraphConnect Europe 2016 - Inside the Spider’s Web: Dependency Management wit...
 
GraphConnect Europe 2016 - Faster Lap Times with Neo4j - Srinivas Suravarapu
GraphConnect Europe 2016 - Faster Lap Times with Neo4j - Srinivas SuravarapuGraphConnect Europe 2016 - Faster Lap Times with Neo4j - Srinivas Suravarapu
GraphConnect Europe 2016 - Faster Lap Times with Neo4j - Srinivas Suravarapu
 
GraphConnect Europe 2016 - Governing Multichannel Services with Graphs - Albe...
GraphConnect Europe 2016 - Governing Multichannel Services with Graphs - Albe...GraphConnect Europe 2016 - Governing Multichannel Services with Graphs - Albe...
GraphConnect Europe 2016 - Governing Multichannel Services with Graphs - Albe...
 
GraphConnect Europe 2016 - How Go and Neo4j enabled the FT to Deliver at Spee...
GraphConnect Europe 2016 - How Go and Neo4j enabled the FT to Deliver at Spee...GraphConnect Europe 2016 - How Go and Neo4j enabled the FT to Deliver at Spee...
GraphConnect Europe 2016 - How Go and Neo4j enabled the FT to Deliver at Spee...
 
Slides from GraphDay Santa Clara
Slides from GraphDay Santa ClaraSlides from GraphDay Santa Clara
Slides from GraphDay Santa Clara
 
Intro to Cypher for the SQL Developer
Intro to Cypher for the SQL DeveloperIntro to Cypher for the SQL Developer
Intro to Cypher for the SQL Developer
 
GraphConnect Europe 2016 - NoSQL Polyglot Persistence: Tools and Integrations...
GraphConnect Europe 2016 - NoSQL Polyglot Persistence: Tools and Integrations...GraphConnect Europe 2016 - NoSQL Polyglot Persistence: Tools and Integrations...
GraphConnect Europe 2016 - NoSQL Polyglot Persistence: Tools and Integrations...
 
GraphConnect Europe 2016 - Enterprise Data Integration with a new JDBC Driver...
GraphConnect Europe 2016 - Enterprise Data Integration with a new JDBC Driver...GraphConnect Europe 2016 - Enterprise Data Integration with a new JDBC Driver...
GraphConnect Europe 2016 - Enterprise Data Integration with a new JDBC Driver...
 
GraphTalk Berlin - Neo4j und FirstSpirit
GraphTalk Berlin - Neo4j und FirstSpiritGraphTalk Berlin - Neo4j und FirstSpirit
GraphTalk Berlin - Neo4j und FirstSpirit
 
GraphConnect Europe 2016 - Digitalization and Optimizing Business Performance...
GraphConnect Europe 2016 - Digitalization and Optimizing Business Performance...GraphConnect Europe 2016 - Digitalization and Optimizing Business Performance...
GraphConnect Europe 2016 - Digitalization and Optimizing Business Performance...
 
GraphConnect Europe 2016 - Securely Deploying Neo4j into AWS - Benjamin Nussbaum
GraphConnect Europe 2016 - Securely Deploying Neo4j into AWS - Benjamin NussbaumGraphConnect Europe 2016 - Securely Deploying Neo4j into AWS - Benjamin Nussbaum
GraphConnect Europe 2016 - Securely Deploying Neo4j into AWS - Benjamin Nussbaum
 
GraphConnect Europe 2016 - IoT - where do Graphs fit with Business Requiremen...
GraphConnect Europe 2016 - IoT - where do Graphs fit with Business Requiremen...GraphConnect Europe 2016 - IoT - where do Graphs fit with Business Requiremen...
GraphConnect Europe 2016 - IoT - where do Graphs fit with Business Requiremen...
 
GraphConnect Europe 2016 - Building Consumer Trust through Transparency, Comp...
GraphConnect Europe 2016 - Building Consumer Trust through Transparency, Comp...GraphConnect Europe 2016 - Building Consumer Trust through Transparency, Comp...
GraphConnect Europe 2016 - Building Consumer Trust through Transparency, Comp...
 
GraphConnect Europe 2016 - Building a Repository of Biomedical Ontologies wit...
GraphConnect Europe 2016 - Building a Repository of Biomedical Ontologies wit...GraphConnect Europe 2016 - Building a Repository of Biomedical Ontologies wit...
GraphConnect Europe 2016 - Building a Repository of Biomedical Ontologies wit...
 

Ähnlich wie GraphConnect Europe 2016 - Building Spring Data Neo4j 4.1 Applications Like A Superhero - Luanne Misquitta

Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
Dmitry Buzdin
 
Easy data-with-spring-data-jpa
Easy data-with-spring-data-jpaEasy data-with-spring-data-jpa
Easy data-with-spring-data-jpa
Staples
 

Ähnlich wie GraphConnect Europe 2016 - Building Spring Data Neo4j 4.1 Applications Like A Superhero - Luanne Misquitta (20)

Introduction To Groovy 2005
Introduction To Groovy 2005Introduction To Groovy 2005
Introduction To Groovy 2005
 
Intro to GraphQL on Android with Apollo DroidconNYC 2017
Intro to GraphQL on Android with Apollo DroidconNYC 2017Intro to GraphQL on Android with Apollo DroidconNYC 2017
Intro to GraphQL on Android with Apollo DroidconNYC 2017
 
Using Neo4j from Java
Using Neo4j from JavaUsing Neo4j from Java
Using Neo4j from Java
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
 
Tomer Elmalem - GraphQL APIs: REST in Peace - Codemotion Milan 2017
Tomer Elmalem - GraphQL APIs: REST in Peace - Codemotion Milan 2017Tomer Elmalem - GraphQL APIs: REST in Peace - Codemotion Milan 2017
Tomer Elmalem - GraphQL APIs: REST in Peace - Codemotion Milan 2017
 
MongoDB.local Berlin: Building a GraphQL API with MongoDB, Prisma and Typescript
MongoDB.local Berlin: Building a GraphQL API with MongoDB, Prisma and TypescriptMongoDB.local Berlin: Building a GraphQL API with MongoDB, Prisma and Typescript
MongoDB.local Berlin: Building a GraphQL API with MongoDB, Prisma and Typescript
 
Overview of GraphQL & Clients
Overview of GraphQL & ClientsOverview of GraphQL & Clients
Overview of GraphQL & Clients
 
Neo4j-Databridge: Enterprise-scale ETL for Neo4j
Neo4j-Databridge: Enterprise-scale ETL for Neo4jNeo4j-Databridge: Enterprise-scale ETL for Neo4j
Neo4j-Databridge: Enterprise-scale ETL for Neo4j
 
Play á la Rails
Play á la RailsPlay á la Rails
Play á la Rails
 
Object Graph Mapping with Spring Data Neo4j 3 - Nicki Watt & Michael Hunger @...
Object Graph Mapping with Spring Data Neo4j 3 - Nicki Watt & Michael Hunger @...Object Graph Mapping with Spring Data Neo4j 3 - Nicki Watt & Michael Hunger @...
Object Graph Mapping with Spring Data Neo4j 3 - Nicki Watt & Michael Hunger @...
 
Data access 2.0? Please welcome: Spring Data!
Data access 2.0? Please welcome: Spring Data!Data access 2.0? Please welcome: Spring Data!
Data access 2.0? Please welcome: Spring Data!
 
Annotation processing and code gen
Annotation processing and code genAnnotation processing and code gen
Annotation processing and code gen
 
GraphQL Los Angeles Meetup Slides
GraphQL Los Angeles Meetup SlidesGraphQL Los Angeles Meetup Slides
GraphQL Los Angeles Meetup Slides
 
Hands On Spring Data
Hands On Spring DataHands On Spring Data
Hands On Spring Data
 
Easy data-with-spring-data-jpa
Easy data-with-spring-data-jpaEasy data-with-spring-data-jpa
Easy data-with-spring-data-jpa
 
Domain-Driven Design with SeedStack
Domain-Driven Design with SeedStackDomain-Driven Design with SeedStack
Domain-Driven Design with SeedStack
 
GraphQL & Prisma from Scratch
GraphQL & Prisma from ScratchGraphQL & Prisma from Scratch
GraphQL & Prisma from Scratch
 
Painless Persistence in a Disconnected World
Painless Persistence in a Disconnected WorldPainless Persistence in a Disconnected World
Painless Persistence in a Disconnected World
 
Scala @ TechMeetup Edinburgh
Scala @ TechMeetup EdinburghScala @ TechMeetup Edinburgh
Scala @ TechMeetup Edinburgh
 
Big Data Day LA 2015 - Compiling DSLs for Diverse Execution Environments by Z...
Big Data Day LA 2015 - Compiling DSLs for Diverse Execution Environments by Z...Big Data Day LA 2015 - Compiling DSLs for Diverse Execution Environments by Z...
Big Data Day LA 2015 - Compiling DSLs for Diverse Execution Environments by Z...
 

Mehr von Neo4j

Mehr von Neo4j (20)

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
QIAGEN: Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
QIAGEN: Biomedical Knowledge Graphs for Data Scientists and BioinformaticiansQIAGEN: Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
QIAGEN: Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
ISDEFE - GraphSummit Madrid - ARETA: Aviation Real-Time Emissions Token Accre...
ISDEFE - GraphSummit Madrid - ARETA: Aviation Real-Time Emissions Token Accre...ISDEFE - GraphSummit Madrid - ARETA: Aviation Real-Time Emissions Token Accre...
ISDEFE - GraphSummit Madrid - ARETA: Aviation Real-Time Emissions Token Accre...
 
BBVA - GraphSummit Madrid - Caso de éxito en BBVA: Optimizando con grafos
BBVA - GraphSummit Madrid - Caso de éxito en BBVA: Optimizando con grafosBBVA - GraphSummit Madrid - Caso de éxito en BBVA: Optimizando con grafos
BBVA - GraphSummit Madrid - Caso de éxito en BBVA: Optimizando con grafos
 
Graph Everywhere - Josep Taruella - Por qué Graph Data Science en tus modelos...
Graph Everywhere - Josep Taruella - Por qué Graph Data Science en tus modelos...Graph Everywhere - Josep Taruella - Por qué Graph Data Science en tus modelos...
Graph Everywhere - Josep Taruella - Por qué Graph Data Science en tus modelos...
 
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jGraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
 
Neo4j_Exploring the Impact of Graph Technology on Financial Services.pdf
Neo4j_Exploring the Impact of Graph Technology on Financial Services.pdfNeo4j_Exploring the Impact of Graph Technology on Financial Services.pdf
Neo4j_Exploring the Impact of Graph Technology on Financial Services.pdf
 
Rabobank_Exploring the Impact of Graph Technology on Financial Services.pdf
Rabobank_Exploring the Impact of Graph Technology on Financial Services.pdfRabobank_Exploring the Impact of Graph Technology on Financial Services.pdf
Rabobank_Exploring the Impact of Graph Technology on Financial Services.pdf
 
Webinar - IA generativa e grafi Neo4j: RAG time!
Webinar - IA generativa e grafi Neo4j: RAG time!Webinar - IA generativa e grafi Neo4j: RAG time!
Webinar - IA generativa e grafi Neo4j: RAG time!
 
IA Generativa y Grafos de Neo4j: RAG time
IA Generativa y Grafos de Neo4j: RAG timeIA Generativa y Grafos de Neo4j: RAG time
IA Generativa y Grafos de Neo4j: RAG time
 
Neo4j: Data Engineering for RAG (retrieval augmented generation)
Neo4j: Data Engineering for RAG (retrieval augmented generation)Neo4j: Data Engineering for RAG (retrieval augmented generation)
Neo4j: Data Engineering for RAG (retrieval augmented generation)
 
Neo4j Graph Summit 2024 Workshop - EMEA - Breda_and_Munchen.pdf
Neo4j Graph Summit 2024 Workshop - EMEA - Breda_and_Munchen.pdfNeo4j Graph Summit 2024 Workshop - EMEA - Breda_and_Munchen.pdf
Neo4j Graph Summit 2024 Workshop - EMEA - Breda_and_Munchen.pdf
 
Enabling GenAI Breakthroughs with Knowledge Graphs
Enabling GenAI Breakthroughs with Knowledge GraphsEnabling GenAI Breakthroughs with Knowledge Graphs
Enabling GenAI Breakthroughs with Knowledge Graphs
 
Neo4j_Anurag Tandon_Product Vision and Roadmap.Benelux.pptx.pdf
Neo4j_Anurag Tandon_Product Vision and Roadmap.Benelux.pptx.pdfNeo4j_Anurag Tandon_Product Vision and Roadmap.Benelux.pptx.pdf
Neo4j_Anurag Tandon_Product Vision and Roadmap.Benelux.pptx.pdf
 
Neo4j Jesus Barrasa The Art of the Possible with Graph
Neo4j Jesus Barrasa The Art of the Possible with GraphNeo4j Jesus Barrasa The Art of the Possible with Graph
Neo4j Jesus Barrasa The Art of the Possible with Graph
 

Kürzlich hochgeladen

Kürzlich hochgeladen (20)

A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
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
 
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...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
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
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
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
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
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...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
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
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 

GraphConnect Europe 2016 - Building Spring Data Neo4j 4.1 Applications Like A Superhero - Luanne Misquitta

  • 1. GraphAware® Build Spring Data Neo4j 4 Applications like a Superhero graphaware.com @graph_aware, @luannem Luanne Misquitta
  • 2. Most active Spring project Convenient data access to (No)SQL databases Consistent API’s Mapping POJOs, Template, Repositories Neo4j, JPA, MongoDB, Redis, CouchBase & more Spring Data GraphAware®
  • 3. Focus on performance Based on a pure Java OGM [Neo4j-OGM] 3 Drivers available to connect to Neo4j HTTP Embedded Bolt Spring Data Neo4j 4.1 GraphAware®
  • 4. Object Graph Mapping from any Java or JVM-based application “Vampire” metadata scanning (no reflection!) “Smart” object mapping Mapping contexts tied to Session lifetimes Application HTTP session/request etc. Support for default and bespoke type conversions Repositories, Neo4jTemplate [SDN] Custom Queries, Derived Finders [SDN] Transactional Support Features GraphAware®
  • 5. Persistence horizon (depth) indicates how many relationships should be traversed in the graph when loading or saving data Default loading depth is 1 Default persistence depth is -1 Variable Depth Persistence GraphAware®
  • 6. It’s a bird, it’s a plane, 
 it’s a superhero graph!
  • 7. Node Entities - Character GraphAware® @NodeEntity(label = "Character") public class Character { @GraphId Long graphId; … private Long id; private String name; private String alias; private String realName;
  • 8. Node Entities - Relationships GraphAware® public class Character { … @Relationship(type = "ALLY_OF", direction = Relationship.UNDIRECTED) @Relationship(type = "ENEMY_OF", direction = Relationship.UNDIRECTED) @Relationship(type = "MEMBER_OF") @Relationship(type = "STARS", direction = Relationship.INCOMING) Set<Character> allies = new HashSet<>(); Set<Character> enemies = new HashSet<>(); Set<Team> teams = new HashSet<>(); Set<Role> roles = new HashSet<>(); Set<Game> gamesFeaturedIn = new HashSet<>(); @Relationship(type = "FEATURED_IN") @Relationship(type = "FEATURED_IN") Set<Comic> comicsFeaturedIn = new HashSet<>();
  • 9. Node Entities - Hierarchy GraphAware® public class Villain extends Character{ … } public class Hero extends Character { …
 } @NodeEntity(label = "Hero") @NodeEntity(label = "Villain")
  • 10. Node Entities - Team GraphAware® @NodeEntity(label = "Team") public class Team { @GraphId private Long graphId; private Long id; private String name; private String operationsBase; @Relationship(type = "MEMBER_OF", direction = "INCOMING") private Set<Character> members = new HashSet<>(); public Team() { }
  • 11. Node Entities - Comic GraphAware® @NodeEntity(label = "Comic") private Long id; private String title; private String author; private String artist; private boolean available; private Binding binding; @DateLong private Date onSaleDate; @Relationship(type = "FEATURED_IN", direction = Relationship.INCOMING) private Set<Character> characters = new HashSet<>(); public enum Binding { SOFT, LEATHER, CLOTH, HARD } public class Comic { @GraphId private Long graphId;
  • 12. Node Entities - Game GraphAware® @NodeEntity(label = "Game") public class Game { @Graphid private Long graphId; private Long id; private String title; private int year; private String publisher; private Rating rating; private Set<Platform> platforms; @Relationship(type = "FEATURED_IN", direction = Relationship.INCOMING) private Set<Character> characters = new HashSet<>(); public enum Platform { PC, WII, XBOX_360, PLAYSTATION_3 }
  • 13. Node Entities GraphAware® @Convert(UrlConverter.class) private URL imdbUrl; @Relationship(type = "STARS") private Set<Role> stars; public class UrlConverter implements AttributeConverter<URL, String> { @Override public String toGraphProperty(URL value) { return value == null? null : value.toString(); } @Override public URL toEntityAttribute(String value) { try { return new URL(value); } catch (MalformedURLException e) { e.printStackTrace(); } return null; }
 } @NodeEntity(label = "Movie") public class Movie { @GraphId private Long graphId; private Long id; private String title; private int year; private Rating rating;
  • 14. Relationship Entities GraphAware® @RelationshipEntity(type = "STARS") public class Role { private Long id; @StartNode private Movie movie; @EndNode private Character character; private String actor;
  • 15. Repositories GraphAware® public interface CharacterRepository<T extends Character> extends GraphRepository<T> { List<T> findByNameLike(String keyword); @Query(" MATCH (c:Character) WHERE ID(c)={characterId} " + "OPTIONAL MATCH (c)-[:ALLY_OF|ENEMY_OF]-(other) " + "WITH c, collect(other) as others " + "OPTIONAL MATCH (c)-[:MEMBER_OF|FEATURED_IN]-> ()<-[:MEMBER_OF|FEATURED_IN]-(teamMember) " + "WITH c, others + collect(teamMember) as othersWithTeam " + "OPTIONAL MATCH (c)<-[:STARS]-()-[:STARS]->(actors) " + "WITH othersWithTeam + collect(actors) as allOthers " + "UNWIND allOthers as related " + "WITH count(*) as count, related " + "RETURN related ORDER BY count DESC") List<Character> findRelatedCharacters(@Param("characterId") Long id);
  • 16. Repositories GraphAware® public interface HeroRepository extends CharacterRepository<Hero> { } public interface VillainRepository extends CharacterRepository<Villain>{ }
  • 17. Services GraphAware® @Service public class CharacterService { @Autowired CharacterRepository<Character> characterRepository; @Autowired HeroRepository heroRepository; @Autowired VillainRepository villainRepository; public List<CharacterSummary> searchHeroesByKeyword(String keyword) { return summarizeCharacter(heroRepository.findByNameLike(getKeywordParam(keyword)) } public List<Character> findRelatedCharacters(Long id) { return characterRepository.findRelatedCharacters(id); } public Character getById(Long id) { return characterRepository.findById(id); } … }
  • 18. Controller GraphAware® @RestController @RequestMapping("/api/") public class CharacterController { @Autowired CharacterService characterService; @RequestMapping(value = "characters/{id}", method = RequestMethod.GET) public Character getCharacterById(@PathVariable("id") Long id) { return characterService.getById(id); } @RequestMapping(value = "characters/{id}/related", method = RequestMethod.GET) public List<Character> getRelatedCharacters(@PathVariable("id") Long id) { return characterService.findRelatedCharacters(id); }
  • 19. SDN 4.1 / Neo4j OGM Driver Configuration GraphAware® driver=org.neo4j.ogm.drivers.http.driver.HttpDriver URI=http://neo4j:neo@localhost:7474 Auto configure with ogm.properties Java Configuration Components.configuration() .driverConfiguration() .setDriverClassName("org.neo4j.ogm.drivers.http.driver.HttpDriver") .setURI("http://user:password@localhost:7474")
  • 20. SDN 4.1 Neo4j Configuration GraphAware® @Configuration @ComponentScan("com.graphaware.superhero") @EnableAutoConfiguration @EnableTransactionManagement @EnableNeo4jRepositories("com.graphaware.superhero.repository") public class Application extends Neo4jConfiguration { public static void main(String[] args) { SpringApplication.run(Application.class, args); } …
  • 21. SDN 4.1 Neo4j Configuration GraphAware® … public class Application extends Neo4jConfiguration { @Override @Bean public SessionFactory getSessionFactory() { return new SessionFactory("com.graphaware.superhero.domain"); } @Override @Bean @Scope(value = "session", proxyMode = ScopedProxyMode.TARGET_CLASS) public Session getSession() throws Exception { return super.getSession(); }
  • 22. Up, up and away! GraphAware® mvn clean spring-boot:run
  • 24. Where to find us GraphAware® Luanne Misquitta Adam George Michal “Batman” Bachman Vince Bickers
  • 25. Getting Help StackOverflow (spring-data-neo4j-4, neo4j-ogm) Slack: neo4j-users (neo4j-sdn) Email the team: spring-data-neo4j@neotechnology.com Raise issues: https://jira.spring.io/browse/DATAGRAPH Twitter: Follow @graph_aware for pro tips Blog: http://graphaware.com/blog