Jennifer Reif
Email: jennifer.reif@neo4j.com
Twitter: @JMHReif
LinkedIn: linkedin.com/in/jmhreif
Github: GitHub.com/JMHReif
Website: jmhreif.com
Pouring Coffee into the Matrix
Building Java applications on Neo4j
Who Am I?
• Developer + Advocate

• Continuous learner

• Technical content writer

• Conference speaker

• Other: geek
Developing applications
Java App Data Store Options
• Relational

• Straight JDBC

• JDBC Template

• JOOQ

• JPA or Hibernate

• NoSQL - Document

• MongoDB

• Graph

• Neo4j
Java dev: Why Graph?
Java domain
• Java Versions (i.e. 8, 11, 17)

• Changes between versions over time

• Di
ff
s
Java Entity - Domain Class
• Class

• Entity/Object

• Represents domain type

• General outline for objects of that type

• Variables/Properties

• Details for that entity

• Values may not always exist

• Constructor - instance of object

• Each instance is unique object with varying info
@Node
@Data
@RequiredArgsConstructor
public class JavaVersion {
@Id
@Property("version")
private
fi
nal String javaVersion;
private String name, codeName, status, apiSpec;
private LocalDate gaDate, eolDate;
}
Java Domain Relationships
• Adding relationships

• Add variable as pointer to another object

• Links entities together

• Might have some annotations for mapping
@Node
@Data
@RequiredArgsConstructor
public class JavaVersion {
@Relationship(“FROM_NEWER”)
private List<VersionDiff> olderVersionDiffs;
}
• Set theory - rows and columns

• Schema - rigid, enforced

• Entities - table row

• Metadata - columns

• Relationships - crafted JOINs

• Queries - JOINs at runtime

• Indexes - Lookups scans
Graphs for Java devs
• Graph theory - entity network

• Schema -
fl
exible, optional

• Entities - node (object)

• Metadata - properties

• Relationships - stored joins

• Queries - joins at write

• Indexes - place to start
Relational database Graph database
Graph Data Model
Property Graph
• Node (vertex)

• Relationship (edge)
Nodes
• Represent objects or entities

• Can be labeled
JavaVersion
VersionDiff
JavaVersion
Nodes
• Represent objects or entities

• Can be labeled

• May have properties
JavaVersion
VersionDiff
JavaVersion
version: “17”


gaDate: 2021-09-14
fromVersion: “17.0.3+7-tem”


toVersion: “1.6.0_45-oracle”
version: “6”


gaDate: 2006-12-12


codeName: “Mustang”
Relationships
• Must have a type

• Must have a direction
JavaVersion
VersionDiff
JavaVersion
version: “17”
ffi
cial)

• Spring Data Neo4j

• Uses Neo4j Java driver at base

• Other options:

• O
ffi
cial drivers-> Python, JavaScript, Go, .NET

• Java frameworks-> Quarkus, Helidon, Micronaut, etc
Spring provisions
• Spring Initializr

• Spring Boot’s reduction of boilerplate

• Annotation-based OGM for POJOs

• Query derivation + DSL for custom (Cypher)

• Spring Data’s easy connection to Neo4j

• BOLT or HTTP
Let’s see some code!
Demo time!
Resources
• Source code: github.com/JMHReif/pouring-co
ff
ee-into-matrix-lombok

• Spring Data Neo4j documentation: dev.neo4j.com/sdn-docs

• Neo4j AuraDB: bit.ly/neo4j-aura

• Blog: bit.ly/jmhreif-blog
Jennifer Reif
Email: jennifer.reif@neo4j.com
Twitter: @JMHReif
LinkedIn: linkedin.com/in/jmhreif
Github: GitHub.com/JMHReif
Website: jmhreif.com

Pouring Coffee Into the Matrix: Building Java Applications on Neo4j

  • 1.
    Jennifer Reif Email: jennifer.reif@neo4j.com Twitter:@JMHReif LinkedIn: linkedin.com/in/jmhreif Github: GitHub.com/JMHReif Website: jmhreif.com Pouring Coffee into the Matrix Building Java applications on Neo4j
  • 2.
    Who Am I? •Developer + Advocate • Continuous learner • Technical content writer • Conference speaker • Other: geek
  • 3.
  • 4.
    Java App DataStore Options • Relational • Straight JDBC • JDBC Template • JOOQ • JPA or Hibernate • NoSQL - Document • MongoDB • Graph • Neo4j
  • 5.
  • 6.
    Java domain • JavaVersions (i.e. 8, 11, 17) • Changes between versions over time • Di ff s
  • 7.
    Java Entity -Domain Class • Class • Entity/Object • Represents domain type • General outline for objects of that type • Variables/Properties • Details for that entity • Values may not always exist • Constructor - instance of object • Each instance is unique object with varying info @Node @Data @RequiredArgsConstructor public class JavaVersion { @Id @Property("version") private fi nal String javaVersion; private String name, codeName, status, apiSpec; private LocalDate gaDate, eolDate; }
  • 8.
    Java Domain Relationships •Adding relationships • Add variable as pointer to another object • Links entities together • Might have some annotations for mapping @Node @Data @RequiredArgsConstructor public class JavaVersion { @Relationship(“FROM_NEWER”) private List<VersionDiff> olderVersionDiffs; }
  • 9.
    • Set theory- rows and columns • Schema - rigid, enforced • Entities - table row • Metadata - columns • Relationships - crafted JOINs • Queries - JOINs at runtime • Indexes - Lookups scans Graphs for Java devs • Graph theory - entity network • Schema - fl exible, optional • Entities - node (object) • Metadata - properties • Relationships - stored joins • Queries - joins at write • Indexes - place to start Relational database Graph database
  • 10.
  • 11.
    Property Graph • Node(vertex) • Relationship (edge)
  • 12.
    Nodes • Represent objectsor entities • Can be labeled JavaVersion VersionDiff JavaVersion
  • 13.
    Nodes • Represent objectsor entities • Can be labeled • May have properties JavaVersion VersionDiff JavaVersion version: “17” gaDate: 2021-09-14 fromVersion: “17.0.3+7-tem” toVersion: “1.6.0_45-oracle” version: “6” gaDate: 2006-12-12 codeName: “Mustang”
  • 14.
    Relationships • Must havea type • Must have a direction JavaVersion VersionDiff JavaVersion version: “17”
  • 25.
    ffi cial) • Spring DataNeo4j • Uses Neo4j Java driver at base • Other options: • O ffi cial drivers-> Python, JavaScript, Go, .NET • Java frameworks-> Quarkus, Helidon, Micronaut, etc
  • 26.
    Spring provisions • SpringInitializr • Spring Boot’s reduction of boilerplate • Annotation-based OGM for POJOs • Query derivation + DSL for custom (Cypher) • Spring Data’s easy connection to Neo4j • BOLT or HTTP
  • 27.
    Let’s see somecode! Demo time!
  • 28.
    Resources • Source code:github.com/JMHReif/pouring-co ff ee-into-matrix-lombok • Spring Data Neo4j documentation: dev.neo4j.com/sdn-docs • Neo4j AuraDB: bit.ly/neo4j-aura • Blog: bit.ly/jmhreif-blog Jennifer Reif Email: jennifer.reif@neo4j.com Twitter: @JMHReif LinkedIn: linkedin.com/in/jmhreif Github: GitHub.com/JMHReif Website: jmhreif.com