{"id":26092910,"url":"https://github.com/jazzshu/graphdb-neo4j","last_synced_at":"2026-04-17T08:01:53.044Z","repository":{"id":143113468,"uuid":"601346701","full_name":"jazzshu/GraphDB-Neo4j","owner":"jazzshu","description":"A basic project to setup a Neo4j DB with Spring ","archived":false,"fork":false,"pushed_at":"2023-02-13T22:10:18.000Z","size":123,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-16T04:33:08.135Z","etag":null,"topics":["graphdb","java","neo4j","spring"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jazzshu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-13T21:49:59.000Z","updated_at":"2023-02-14T13:59:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"34ae61ec-63dd-42f8-abc2-d4afa9438a2d","html_url":"https://github.com/jazzshu/GraphDB-Neo4j","commit_stats":null,"previous_names":["jazzshu/graphdb-neo4j"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jazzshu/GraphDB-Neo4j","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jazzshu%2FGraphDB-Neo4j","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jazzshu%2FGraphDB-Neo4j/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jazzshu%2FGraphDB-Neo4j/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jazzshu%2FGraphDB-Neo4j/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jazzshu","download_url":"https://codeload.github.com/jazzshu/GraphDB-Neo4j/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jazzshu%2FGraphDB-Neo4j/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31920518,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-16T18:22:33.417Z","status":"online","status_checked_at":"2026-04-17T02:00:06.879Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["graphdb","java","neo4j","spring"],"created_at":"2025-03-09T11:10:28.597Z","updated_at":"2026-04-17T08:01:53.021Z","avatar_url":"https://github.com/jazzshu.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Spring - Neo4J\n\nThis is a basic implementation of a Graph DB, in particular Neo4j with the Spring framework.\nFirst of all you need to download and install Neo4j on your local machine, or simple pull the Docker image as I did with the following command:\n```shell\ndocker pull neo4j\n```\n\nAfter that, start the container with:\n```shell\ndocker run --publish=7474:7474 --publish=7687:7687 --volume=$HOME/neo4j/data:/data neo4j\n```\n\nOne the container is up we can start building our project.\nUsing Spring Initializer you must choose Java 17 in order for Neo4j to work, \nthen as the dependencies choose the following ones for Gradle or Maven (**spring-boot-starter-data-neo4j** and **lombok**):\n```xml\n\u003cdependencies\u003e\n    \u003cdependency\u003e\n        \u003cgroupId\u003eorg.springframework.boot\u003c/groupId\u003e\n        \u003cartifactId\u003espring-boot-starter-data-neo4j\u003c/artifactId\u003e\n    \u003c/dependency\u003e\n    \u003cdependency\u003e\n        \u003cgroupId\u003eorg.projectlombok\u003c/groupId\u003e\n        \u003cartifactId\u003elombok\u003c/artifactId\u003e\n        \u003cversion\u003e1.18.26\u003c/version\u003e\n        \u003cscope\u003eprovided\u003c/scope\u003e\n    \u003c/dependency\u003e\n\u003c/dependencies\u003e\n```\nAfter you updated and built your project you can start creating your entities.\n\n### Entities\nI created 3 entities: Person, Dog and Toy. \n\nPerson has a single property (obviously without considering the Id), which a String for its name.\nDog has a single property as well for its race and Toy has 2 properties which are price and name.\n\nEach of these entities need to be annotated with @Node.\nThe id's need to be annotated with @Id and @GeneratedValue. These 3 annotations are imported from **import org.springframework.data.neo4j.core.schema**.\n\n### Relationships\nThe Person entity has 2 relationships: TEAMMATE and OWNS.\nA Person can have one or more Teammates (which is another Person entity), and can own a Dog.\nTo create a relationship this is the syntax:\n\n```java\n@Relationship(type = \"TEAMMATE\")\n    public Set\u003cPerson\u003e teammates;\n\n    @Relationship(type = \"OWNS\")\n    public Set\u003cDog\u003e dogs;\n\n    public void worksWith(Person person) {\n        if(teammates == null) {\n            teammates = new HashSet\u003c\u003e();\n        }\n        teammates.add(person);\n    }\n\n    public void owns(Dog dog) {\n        if(dogs == null) {\n            dogs = new HashSet\u003c\u003e();\n        }\n        dogs.add(dog);\n    }\n```\nAs you can see, teammates and dogs are both a Set as they are sort of a \"One-To-Many\" relationship in relational databases.\n\nA Dog can have a relationship of type \"PLAYS_WITH\" with a Toy Entity, while Toy has no entity with anyone.\n\nWith the methods we defined it is fairly simple to implements relationships between entities as we can see in our main method:\n```java\nPerson greg = new Person(\"Greg\");\nPerson roy = new Person(\"Roy\");\nPerson craig = new Person(\"Craig\");\nDog labrador = new Dog(\"Labrador\");\nDog pitbull = new Dog(\"Pitbull\");\nDog chihuaha = new Dog(\"Chihuaha\");\nDog amstaff = new Dog(\"Amstaff\");\nToy ball = new Toy(12.3, \"Ball\");\nToy chain = new Toy(2.3, \"Chain\");\nToy doll = new Toy(1.4, \"Doll\");\n\nList\u003cPerson\u003e team = Arrays.asList(greg, roy, craig);\nlog.info(\"Before linking up to Neo4j..\");\n\npersonRepository.save(greg);\npersonRepository.save(roy);\npersonRepository.save(craig);\n\ngreg = personRepository.findByName(greg.getName());\ngreg.worksWith(roy);\ngreg.owns(labrador);\ngreg.owns(pitbull);\nlabrador.playsWith(ball);\nlabrador.playsWith(chain);\npitbull.playsWith(chain);\ngreg.worksWith(craig);\ncraig.owns(chihuaha);\nchihuaha.playsWith(chain);\ncraig.owns(labrador);\nchihuaha.playsWith(doll);\nroy.owns(amstaff);\npersonRepository.save(greg);\n```\n\nHere we can see that we created various relationships between entities and no joins were needed.\nRemember to annotate your main class with @EnableNeo4jRepositories.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjazzshu%2Fgraphdb-neo4j","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjazzshu%2Fgraphdb-neo4j","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjazzshu%2Fgraphdb-neo4j/lists"}