combine spring data neo4j and spring boot to quickl
DESCRIPTION
Speakers: Michael Hunger (Neo Technology) and Josh Long (Pivotal) Spring Data Neo4j 3.0 is here and it supports Neo4j 2.0. Neo4j is a tiny graph database with a big punch. Graph databases are imminently suited to asking interesting questions, and doing analysis. Want to load the Facebook friend graph? Build a recommendation engine? Neo4j's just the ticket. Join Spring Data Neo4j lead Michael Hunger (@mesirii) and Spring Developer Advocate Josh Long (@starbuxman) for a look at how to build smart, graph-driven applications with Spring Data Neo4j and Spring Boot.TRANSCRIPT
![Page 1: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/1.jpg)
S P R I NG DATA N EO 4 J
github.com/jexp/sdn-‐twi5er-‐boot
WI TH S P R I NG BOOT
Michael Hunger Josh Long
@mesirii @starbuxman
![Page 2: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/2.jpg)
Twi5er Graph
To become part of todays Twitter-Graph
✓your attendance
✓questions
✓remarks
✓....
please tweet with #springdata #neo4j
![Page 3: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/3.jpg)
1. NOSQL, Connected Data,
2. Graph Databases and Neo4j
3. Spring Data Neo4j
4. Twitter-Graph - Sample App
5. Summary
6. Q & A
Agenda
![Page 4: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/4.jpg)
NOSQL -‐ Not Only SQL
![Page 5: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/5.jpg)
NOSQL
RelationalGraph
DocumentKeyValue
Riak
Column oriented
Redis
Cassandra
Mongo
Couch
Neo4j
MySQL Postgres
NOSQL Databases
![Page 6: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/6.jpg)
RDBMS
Den
sity
~=
Com
plex
ity
Column Family
Volume ~= Size
Key-Value Store
Document Databases
Graph Databases
90% of
use cases
Volume vs. Complexity
![Page 7: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/7.jpg)
Trends in BigData / NOSQL
1. increasing data size (big data)
•“Every 2 days we create as much information as we did up to 2003” - Eric Schmidt
2. increasingly connected data (graph data)
• for example, text documents to html
3. semi-structured data
• individualization of data, with common sub-set
4. architecture - a facade over multiple services
![Page 8: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/8.jpg)
Graph Databases
![Page 9: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/9.jpg)
8
Graph Database Use Cases
![Page 10: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/10.jpg)
EvoluJon of Web Search
Pre-1999 WWW Indexing
Atomic Data
9
1999 - 2012 Google Invents
PageRank
Simple Connected Data
2012-? Google Launches the
Knowledge Graph
Rich Connected Data
![Page 11: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/11.jpg)
EvoluJon of Online Job Search
2010-11 Resume Scoring
Atomic Data
2011-12 Social Job Search
Connected Data
X
![Page 12: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/12.jpg)
Social Network
10
![Page 13: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/13.jpg)
(Network) Impact Analysis
11
![Page 14: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/14.jpg)
PracJcal Cypher
CREATE !! (crm {name:"CRM"}),!! (dbvm {name:"Database VM"}),!! (www {name:"Public Website"}),!! (wwwvm {name:"Webserver VM"}),!! (srv1 {name:"Server 1"}),!! (san {name:"SAN"}),!! (srv2 {name:"Server 2"}),!!! (crm)-[:DEPENDS_ON]->(dbvm),!! (dbvm)-[:DEPENDS_ON]->(srv2),!! (srv2)-[:DEPENDS_ON]->(san),!! (www)-[:DEPENDS_ON]->(dbvm),!! (www)-[:DEPENDS_ON]->(wwwvm),!! (wwwvm)-[:DEPENDS_ON]->(srv1),!! (srv1)-[:DEPENDS_ON]->(san)!
X
![Page 15: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/15.jpg)
PracJcal Cypher
// Server 1 Outage!MATCH (n)<-[:DEPENDS_ON*]-(upstream)!WHERE n.name = "Server 1"!RETURN upstream!
X
upstream
{name:"Webserver VM"}
{name:"Public Website"}
![Page 16: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/16.jpg)
PracJcal Cypher
// Public website dependencies!MATCH (n)-[:DEPENDS_ON*]->(downstream)!WHERE n.name = "Public Website"!RETURN downstream!!
X
downstream{name:"Database VM"}{name:"Server 2"}
{name:"SAN"}{name:"Webserver VM"}
{name:"Server 1"}
![Page 17: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/17.jpg)
PracJcal Cypher
// Most depended on component!MATCH (n)<-[:DEPENDS_ON*]-(dependent)!RETURN n, !
count(DISTINCT dependent) !AS dependents!
ORDER BY dependents DESC!LIMIT 1
X
n dependents
{name:"SAN"}
6
![Page 18: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/18.jpg)
12
Route Finding
![Page 19: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/19.jpg)
RecommendaJons
13
![Page 20: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/20.jpg)
LogisJcs
14
![Page 21: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/21.jpg)
Access Control
15
![Page 22: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/22.jpg)
Workflow Management
16
![Page 23: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/23.jpg)
Fraud Analysis
17
![Page 24: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/24.jpg)
4
Facebook Graph Search
Everyone is Talking about Graphs
![Page 25: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/25.jpg)
19
And Everyone is Using them
![Page 26: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/26.jpg)
Graph Databases
![Page 27: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/27.jpg)
21
user accountuser_account
You know RelaJonal
![Page 28: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/28.jpg)
22
Properties (key value pairs)
+ Indexes (finding start points)
Emil
Andrés
Lars
Johan
Allison
Peter
Michael
Tobias
Andreas
IanMica
Delia
knows
knows
knowsknows
knows
knows
knows
knows
knows
knowsMica
knowsknowsMica
Delia
knows
The Property Graph Model
Labels (categorize nodes)
Nodes
Relationships
![Page 29: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/29.jpg)
• a sample social graph –with ~1,000 persons
• average 50 friends per person • pathExists(a,b) limited to depth 4 • caches warmed up to eliminate disk I/O
# persons query time
Relational database 1.000 2000ms
Neo4j 1.000 2ms
Neo4j 1.000.000
But what about Performance?
![Page 30: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/30.jpg)
4
Andreas Peter
Emil
Allison
knows
knows knows
knows
Whiteboard Friendlyness
![Page 31: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/31.jpg)
Andreas
How do I query this Graph?
MATCH (poster:User {name:"Andreas"}) -[:POSTED]->(tweet) -[:MENTIONED]->(user)RETURN distinct user.name
![Page 32: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/32.jpg)
Example: Graph Search!
26
![Page 33: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/33.jpg)
Translate to Cypher
27
MATCH (person:Person)-[:IS_FRIEND_OF]->(friend), (friend)-[:LIKES]->(restaurant),
(restaurant)-[:LOCATED_IN]->(loc:Location), (restaurant)-[:SERVES]->(type:Cuisine) !WHERE person.name = 'Philip' AND loc.location='New York' AND type.cuisine='Sushi' !RETURN restaurant.name
* Cypher query language examplehttp://maxdemarzi.com/?s=facebook
![Page 34: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/34.jpg)
28
Execute the Query
![Page 35: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/35.jpg)
4
Neo4j -‐ A Graph Database?
![Page 36: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/36.jpg)
4
- A Graph Database:
- a schema-free Property Graph
- perfect for complex, highly connected data
- A Graph Database:
- reliable with real ACID Transactions
- scalable: billions nodes and relationships
- fast with millons traversals / second
- Server with REST API, or Embeddable on the JVM
- higher-performance with High-Availability (read scaling)
(Neo4j)-‐[:IS_A]-‐>(Graph Database)
![Page 37: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/37.jpg)
4
– Declarative query language
– Describe what you want, not how
– Based on pattern matching
– First level support for graph concepts and collections
MATCH (tag:Tag {tag:"springdata"})MATCH (poster)-[:POSTED]->(tweet)<-[:TAGGED]-(tag)WHERE poster.age > 18RETURN poster.name, collect(tweet.date) as dates, count(*)ORDER BY count(*) DESCLIMIT 10
Cypher -‐ A Graph Query Language
![Page 38: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/38.jpg)
![Page 39: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/39.jpg)
Spring Data
• Easy access to NoSQL databases for Spring developers
• Consistent APIs and concepts – configuration, repositories, object-mapping – don't hide power of each database
• Shared common infrastructure • Support for several NOSQL approaches
(Neo4j, MongoDB, Redis, Hadoop, …)
33
http://projects.spring.io/spring-data
![Page 40: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/40.jpg)
Spring Data Neo4j
• Uses annotations to define graph entities • Entity state backed by graph database • Two modes of Object Graph Mapping
• simple POJO Graph Mapping • advanced, seamless AspectJ backed Mapping
• SD-Repositories support • Template, Config, Lifecycle • Neo4j Server Support
34
http://projects.spring.io/spring-data-neo4j
![Page 41: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/41.jpg)
Spring Data News
• Spring Data Dijkstra Release is Today • Includes Spring Data Neo4j 3.1.GA
35
http://projects.spring.io/spring-data
![Page 42: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/42.jpg)
Sample Spring Data Neo4j + Boot ApplicaJon
36
github.com/jexp/sdn-twitter-boot
• uses Spring Social (minimally)
• Simple Domain: Tweets, Users, Tags
• connected Entities
• Repositories, Service
• Standalone Application with spring-boot
• either embedded Neo4j-Database, or
• local Neo4j-Server
![Page 43: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/43.jpg)
Domain Model
37
:Tweet
MENTIONS
:Tweet:User
:User
POSTEDPOSTED
:TagTAGGED
TAGGED
:Tag
TAGGED
![Page 44: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/44.jpg)
Spring Data Book
• Written by Spring Data Leads • Covers most SD projects
38
50 e-book copies available for you!
![Page 45: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/45.jpg)
• Wednesday, Oct. 22 - graphconnect.com
• Only conference focused on graphDBs and applications powered by graphs
• Register now for $99 Alpha Geek Passes, Neo4j training courses additional $99
GRAPHCONNECT! SF 2014
![Page 46: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/46.jpg)
• Visit http://neo4j.com
• Learn Online http://graphacademy.com
• Spring Data Neo4j http://spring.io/projects
LEARN MORE!ABOUT NEO4j
![Page 47: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/47.jpg)
41
Thank You!QuesDons?
@starbuxman | @mesirii
![Page 48: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/48.jpg)
Introducing The Twitter-
![Page 49: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/49.jpg)
Whiteboard it -‐ abstract
:Tweet
MENTIONS
:Tweet:User
:User
POSTEDPOSTED
:TagTAGGED
TAGGED
:Tag
TAGGED
![Page 50: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/50.jpg)
Whiteboard friendly -‐ example
Attending the #SDN #Neo4j meetup
MENTIONS Looking
forward to my
@peterneub
POSTEDPOSTED
#Neo4jTAGGED
TAGGED
#SDN
TAGGED
![Page 51: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/51.jpg)
Spring Data
![Page 52: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/52.jpg)
Spring Data
๏Spring Data: Pivotal initiative to give Spring developers easy access to the emerging world of NOSQL
๏Build on top of common infrastructure
๏Spring Data Neo4j is the integration library for Neo4j
๏http://projects.spring.io/spring-data
๏Support for other NOSQL approaches
![Page 53: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/53.jpg)
Spring Data Neo4j
๏The brain child of Rod Johnson & Emil Eifrém
•Wrote functional initial prototype
•Developed by Neo Technology and SpringSource teams
๏Uses annotations to define graph entities
๏Entity state backed by graph database
๏Two modes of Object Graph Mapping
• simple POJO Graph Mapping
![Page 54: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/54.jpg)
public class Tag { private final Node underlyingNode;! Tag( final Node node ) { underlyingNode = node; }! public Node getUnderlyingNode() { return underlyingNode; }! public final String getTag() { return (String) underlyingNode.getProperty( “tag” );
Classic Neo4j domain class
![Page 55: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/55.jpg)
!!!! ! @Indexed(unique = true)
!!!!@NodeEntitypublic class Tag { @GraphId private Long id; private String tag;}
Spring Data Neo4j domain class
![Page 56: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/56.jpg)
Defining enJty classes
•@NodeEntity
• Represents a node in the graph
• Fields saved as properties on node
• Object references stored as relationships between nodes
• Instantiated using Java ‘new’ keyword, like any POJO
• Also returned by lookup mechanisms
• Type information stored in the graph as
![Page 57: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/57.jpg)
Defining enJty classes
•@RelationshipEntity
• Represents a relationship in the graph
• Fields saved as properties on relationship
• Special fields for start- and end-nodes
• Only returned by lookup methods
![Page 58: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/58.jpg)
!@NodeEntitypublic class Tweet {@GraphId private Long id;
!@Indexed(unique=true) Long tweetId;!String text;
!@Fetch User sender; // eager loading
!@RelatedTo(type="TAGGED") Collection<Tag> tags;
Tweet domain class
![Page 59: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/59.jpg)
53
Interface based Repositories๏based on Repository infrastructure in Spring Data Commons
๏ just define the interface and the namespace configuration
๏provide out-of-the-box support for
•CRUD-Operations
• Index-Lookups
•Traversal-Execution
•Annotated Graph-Queries (Cypher, Gremlin)
![Page 60: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/60.jpg)
Repositoriesinterface TweetRepository extends GraphRepository<Tweet> { Tweet findByTweetId(String id); Collection<Tweet> findByTagsTag(String tag);}@EnableNeo4jRepositories("org.neo4j.twitter_graph.repositories")@Configuration
@Controllerpublic class TwitterController { @Autowired TweetRepository tweetRepository;! @RequestMapping(value = "/tweet/{id}",...) public String show(Model model, @PathVariable String id) { Tweet tweet = tweetRepository.findByTweetId(id); model.addAttribute("tweet", tweet); return "/tweet/show";
54
![Page 61: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/61.jpg)
55
Neo4j-Template (I)
๏well known Spring Template Pattern
๏Resource / Transaction Management
๏Convenience Methods
๏Nodes and Entities handling & conversion
๏Fluent Query Result Handling
๏Works also via REST with Neo4j-Server
๏Exception Translation
![Page 62: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/62.jpg)
56
REST-Client-Support
!
๏drop-in replacement for the embedded GraphDatabase
๏works transparently with POJO-Entity-Mapping and Neo4j-Template
@EnableNeo4jRepositories@Configurationclass MyConfig extends Neo4jConfiguration { @Bean public GraphDatabaseService graphDatabaseService() { return new SpringRestGraphDatabase(URL); } }
![Page 63: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/63.jpg)
57
Cypher Query Language
๏Declarative query language
•Describe what you want, not how
•Based on graph patterns
•Expressive - easy to read and learn
•Powerful
‣Read and write operations
‣Support for graph concepts
![Page 64: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/64.jpg)
58
Cypher Query Language๏Write-Queries create graph structures
•Add follows to a user
•Create a complete tweet.
MERGE (user:User {user:"starbuxman"})FOREACH (name in ["ah3rz","springsource","mesirii"] | MERGE (other:User {user:name}) MERGE (user)-[:FOLLOWS]->(other))!MATCH (user:User {name:"mesirii"})CREATE (tweet:Tweet {text:"Love to work with
@starbuxman on #SpringData #Neo4j demos"})<-[:POSTED]-(user))
FOREACH (tag in ["SpringData","Neo4j"] | MERGE (t:Tag {tag:tag}) MERGE (tweet)-[:TAGGED]->(t))
![Page 65: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/65.jpg)
59
Cypher Query Language๏Read-Queries answer use-case questions
•Whom should I follow?
•Which tags where often used with "java"?
MATCH (me:User {user:"starbuxman"})MATCH (me)-[:POSTED]->(tweet)-[:MENTIONS]->(user)WHERE not (me)-[:FOLLOWS]-(user)RETURN user!MATCH (tag:Tag {tag:"java"}) MATCH (tag)<-[:TAGGED]-(tweet)-[:TAGGED]->(co_tag)RETURN co_tag.tag, COUNT(*) as cntORDER BY cnt DESC LIMIT 10
![Page 66: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/66.jpg)
Spring Data NEW
![Page 67: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/67.jpg)
61
Spring Boot
๏Rapid Application Development
๏Like a dynamic programming enviroment but in Java & Spring
๏spring-boot-starter
๏spring-data, spring-data-neo4j, spring-data-rest
๏web, thymeleaf
![Page 68: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/68.jpg)
62
Spring Data Neo4j 3.x
๏Support for Neo4j 2.x
๏Support for Labels
๏Support for "optional schema"
๏ Indexes + Constraints
๏New Cypher Syntax
๏Supports geospatial primitives
![Page 69: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/69.jpg)
63
Coding the Twitter-
![Page 70: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/70.jpg)
64
Todays Coding Exercise
๏uses Spring Social (minimally)
๏Simple Domain: Tweets, Users, Tags
•connected Entities
•Repositories, Service
๏Standalone Application with spring-boot
•either embedded Neo4j-Database, or
![Page 71: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/71.jpg)
65
Demo Time
![Page 72: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/72.jpg)
X
Spring Data Neo4j Guidebook “Good Relationships”
๏Spring Data Neo4j comes with a great Guide Book, featuring:
•Forewords by Rod Johnson and Emil Eifrem
•An easy to read, narrative tutorial walkthrough for cineasts.net
“I’m excited about Spring Data Neo4j.... Spring Data Neo4j makes working with Neo4j amazingly easy, and therefore has the potential to make you more successful as a developer.”
Rod Johnson, founder of Spring
![Page 73: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/73.jpg)
http://cineasts.net
Check Out: http://spring.neo4j.org/tutorial
![Page 74: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/74.jpg)
66
O‘Reilly Spring Data Book „Modern Data Access for Enterprise
• book by the Spring Data project leads
• introduction to Spring Data & SD-repositories
•covers all subprojects
•e-book available for YOU,
![Page 75: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/75.jpg)
ConJnue here๏See the Spring Data Neo4j site for more info:
http://spring.neo4j.org
๏Again, don’t miss our guidebook on Spring Data Neo4j published by InfoQ also printedhttp://bit.ly/sdn-book
๏All about Neo4j: http://neo4j.org
๏Neo4j & SDN videos and webinars: http://video.neo4j.org
๏ local Neo4j meetup groupshttp://neo4j.meetup.com
![Page 76: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/76.jpg)
• 5/13 - How eBay Now (Shutl) delivers even faster using Neo4j at eBay in San Jose
• 5/20 - WEBINAR: Data-Driven Applications with Spring and Neo4j
• 5/23 - Let Me Graph That For You with Ian Robinson, co-author of Graph Databases, at Hack Reactor in SF
• 5/28 - GraphPANEL Silicon Valley at AOL in Palo Alto
• And more at: meetup.com/graphdb-sf
UPCOMING EVENTS
![Page 77: Combine Spring Data Neo4j and Spring Boot to quickl](https://reader033.vdocuments.us/reader033/viewer/2022051412/54c651d54a7959ad7b8b461c/html5/thumbnails/77.jpg)
68
Thank You!Feel free to reach out with questions on !•Twitter @starbuxman, @mesirii, •Spring-Forums, •Neo4j-Google-Group •Stack-Overflow