Skip to content

Thoughtscript/java_spring_graph_2025

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

java_spring_graph_2025

Having some fun with Spring Boot 3.4.3, Neo4J, and Graph Databases.

AWS defines Graph Databases as follows:

"A graph database is a systematic collection of data that emphasizes the relationships 
between the different data entities. The NoSQL database uses mathematical graph theory 
to show data connections."

I've used Graph-Theoretic approaches in several ways:

  1. NoSQL - relational aggregation (in leiu of JOIN statements, JOIN tables, Map-Reduce operations, and/or multiple DBRefs) - mostly a mix of Mongo DB, Dynamo DB.
  2. GraphQL
  3. A bit of AWS Neptune and Neo4J (but without standing up the DB's or configuring them).

Neo4J Cypher uses ASCII Art Syntax for queries typified by the scheme:

  • (nodes)-[:CONNECT_TO]→(otherNodes)
  • (MyNode)-[:VERB_OR_RELATION_TO]→(MyOtherNode)

Use

Docker Compose

docker-compose up

# If using Docker Compose Engine V2:
docker compose up

SSL

keytool -genkey \
  -alias bootexample \
  -keystore bootexample.p12 \
  -storetype PKCS12 \
  -keyalg RSA \
  -storepass af3DF*34afefwefehu \
  -validity 730 \
  -keysize 4096

Tests, Testing, and Queries

Exec into the neo4j instance:

cypher-shell -u neo4j -p examplepw

$ > Match (c:Course {name: "Art"}) - [r:HAS_STUDENT] -> (s:Student) RETURN c, collect(r), collect(s);

$ > MATCH (c:Course {name: "Art"}) RETURN c;

$ > MATCH (s:Student {firstname: "Class", lastname: "Dunce"}) RETURN s;

Other CQL queries are available here.

(Some) Acceptance and Live Integration Tests are available here through Postman. (Some example Unit Tests have also been added and configured.)

Neo4J

  • Access to the built-in view here is now deprecated.
  • Using the recommended docker-compose.yml setting: NEO4J_AUTH=neo4j/examplepw doesn't appear to stick. One can still log in afterwards with neo4j/neo4j (the default, and it will request an immediate password change).
    • As such, I've opted to use neo4j-admin set-initial-password examplepw in the Dockerfile instead.

Resources and Links

  1. https://docs.spring.io/spring-data/neo4j/reference/getting-started.html
  2. https://neo4j.com/docs/cypher-manual/current/queries/concepts
  3. https://aws.amazon.com/nosql/graph
  4. https://www.liquidweb.com/blog/neo4j-graph-database-installing-neo4j-on-ubuntu-20-04/
  5. https://github.com/neo4j-examples/movies-java-spring-data-neo4j/tree/main
  6. https://www.baeldung.com/spring-data-neo4j-intro
  7. https://neo4j.com/docs/operations-manual/current/docker/docker-compose-standalone/

About

Java Spring Boot Graph DB

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published