The document summarizes Spring Data Neo4j 4.0, a new version of the Spring Data project that provides integration with the Neo4j graph database. It describes Neo4j and Spring Data briefly, then outlines the key features and architecture of SDN 4.0, including a standalone object-graph mapping layer, variable depth persistence, and integration with Spring and repositories. It demonstrates a sample conference application built with SDN 4.0 and provides information on getting started and support resources.
2. Agenda
● A bit about Neo4j and the Spring Data project
● A brief history of SDN
● SDN 4: Spring Data + Standalone Java OGM
● Conference Demo
o Data model
o Code
o Live demo!
● Roadmap
● Q & A
3. Neo4j is a Graph Database
•Nodes & Edges (Relationships)
•Index-free adjacency means super-fast traversals
•Embedded Client and Remote Server
•Schema-flexible!
•Cypher Query Language
5. Spring Data
•Most active Spring Project
•Consistent APIs to access both RDBMS and NoSQL stores
•JPA, Neo4j, MongoDB, Redis, CouchBase…
•Convenient abstractions for Spring developers
6. Quick History of SD-Neo4j
● SDN 0.x - Rod and Emil wrote it, started Spring Data efforts
● SDN 1.x - Embedded Neo4j, Object Mapping, Templates
● SDN 2.x - Neo4j Server, SD-Repositories
● SDN 3.x - Neo4j 2.x with Label + Schema Index Support, etc.
7. Now… Spring Data Neo4j 4.0
● New and Shiny!
o Complete rewrite
o Neo4j Server only (for now, at least)
o Sympathetic to typical business use cases
o And … not just for Spring developers!
8. Spring Data Neo4j 4 - Progress
● Development started Sep 2014
● Milestone 1 released end Mar 2015
● RC1 end-May 2015
● GA … mid-June 2015
9. Spring Data + Separate OGM
● Standalone Java OGM
● Spring+
o Template methods
o Transactions
o Repositories
o Queries
o Exception Translation
o Conversion Services
25. Repositories
interface SpeakerRepository extends GraphRepository<Speaker> {
@Query("MATCH(s:Speaker)-[:PRESENTS]->()
return s, count(*) as hits ORDER BY hits DESC")
Iterable<Map<String,Object>> speakersByNumberOfTalks();
}
26. Services - abstraction
public abstract class GenericCRUDService<T> implements Service<T> {
private static final int DEPTH_LIST = 0;
private static final int DEPTH_ENTITY = 1;
@Override
public Iterable<T> findAll() {
return getRepository().findAll(DEPTH_LIST);
}
@Override
public T find(Long id) {
return getRepository().findOne(id, DEPTH_ENTITY);
}
public abstract GraphRepository<T> getRepository();
}
27. Services - implementation
@Service
public class SpeakerService extends GenericCRUDService<Speaker> {
@Autowired
private SpeakerRepository repository;
@Override
public GraphRepository<Speaker> getRepository() {
return repository;
}
}
28. Controllers - abstraction
@RequestMapping(value = "/api")
public abstract class Controller<T> {
public Iterable<T> list() {
return getService().findAll();
}
public T create (T entity) {
return getService().createOrUpdate(entity);
}
// … more controller methods here
public abstract Service<T> getService();
}
29. Controllers - implementation
// controller methods get an @ResponseBody annotation by default, yay!
@RestController
public class TalkController extends Controller<Talk> {
@Autowired private TalkService service;
@RequestMapping(value="/talks", method = RequestMethod.GET)
public Iterable<Talk> list() {
return service.findAll();
}
}
30. Front end: Angular js
● Very simple CRUD application
● Loosely based on jHipster angular templates
● Each JSON entity (track, speaker, etc) fully supported by 5 files:
o config.js
o servicefactory.js
o controllers.js
o list.html
o detail.html
32. Where next?
Immediately after RC1:
● Project code split
● General release mid-June
● More features planned
o Dynamic Properties
o Support for Embedded Neo4j
o Versioning (MVCC)
o Automatic hooks to pre/post-save lifecycle events
o Binary protocol …etc.
33. Getting started
Neo4j: http://neo4j.com/download
SDN4 Conference Application: https://github.com/neo4j-examples/sdn4-
conference
Spring Data Neo4j (4)
Current Release: http://maven.springframework.org/milestone/org/springframework/
data/spring-data-neo4j/4.0.0.M1
Latest Build: http://repo.spring.io/libs-snapshot/org/springframework/data/spring-data-
neo4j/4.0.0.BUILD-SNAPSHOT
Code: https://github.com/spring-projects/spring-data-neo4j/tree/4.0
Documentation: http://docs.spring.io/spring-data/neo4j/docs/4.0.0.M1
34. GraphAware
TM
Getting help
Luanne Misquitta
Adam George
Vince Bickers
Want to track/raise an issue?
○ https://jira.spring.io/browse/DATAGRAPH
Got questions, or need some advice?
○ Check our blog:
http://graphaware.com/blog/
○ Stack Overflow is your friend
graphaware.com
@graph_aware