• Stars
    star
    322
  • Rank 125,906 (Top 3 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created over 9 years ago
  • Updated 15 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Java Object-Graph Mapping Library for Neo4j

https://github.com/neo4j/neo4j-ogm/actions/workflows/maven.yml Maven Central stackoverflow

Neo4j-OGM - An Object Graph Mapping Library for Neo4j.

Neo4j-OGM is a fast object-graph mapping library for Neo4j, optimised for server-based installations utilising Cypher.

It aims to simplify development with the Neo4j graph database and like JPA, it uses annotations on simple POJO domain objects.

Please have a look at the current supported versions and which combinations we recommend: Recommended versions

Quick start

Dependencies for Neo4j-OGM

Maven

<dependency>
    <groupId>org.neo4j</groupId>
    <artifactId>neo4j-ogm-core</artifactId>
    <version>4.0.5</version>
</dependency>

<dependency> <!-- If you're using the Bolt driver -->
    <groupId>org.neo4j</groupId>
    <artifactId>neo4j-ogm-bolt-driver</artifactId>
    <version>4.0.5</version>
</dependency>

Gradle

dependencies {
    compile 'org.neo4j:neo4j-ogm-core:4.0.5'
    compile 'org.neo4j:neo4j-ogm-bolt-driver:4.0.5'
}

Set up domain entities

@NodeEntity
public class Actor {

	@Id @GeneratedValue
	private Long id;
	private String name;

	@Relationship(type = "ACTS_IN", direction = Relationship.OUTGOING)
	private Set<Movie> movies = new HashSet<>();

	public Actor() {
	}

	public Actor(String name) {
		this.name = name;
	}

	public void actsIn(Movie movie) {
		movies.add(movie);
		movie.getActors().add(this);
	}
}

@NodeEntity
public class Movie {

	@Id @GeneratedValue
	private Long id;
	private String title;
	private int released;

	public Movie() {
	}

	public Movie(String title, int year) {
		this.title = title;
		this.released = year;
	}

}

Configuration

The either configure Neo4j-OGM with properties files, or programmatically.

Please see examples here.

Persist/Load entities

//Set up the Session
SessionFactory sessionFactory = new SessionFactory(configuration, "movies.domain");
Session session = sessionFactory.openSession();

Movie movie = new Movie("The Matrix", 1999);

Actor keanu = new Actor("Keanu Reeves");
keanu.actsIn(movie);

Actor carrie = new Actor("Carrie-Ann Moss");
carrie.actsIn(movie);

//Persist the movie. This persists the actors as well.
session.save(movie);

//Load a movie
Movie matrix = session.load(Movie.class, movie.getId());
for(Actor actor : matrix.getActors()) {
    System.out.println("Actor: " + actor.getName());
}

Getting Help

The reference guide is the best place to get started.

You can also post questions in our community forums or on StackOverflow.

Building locally

To use the latest development version, just clone this repository and run mvn clean install.

The tests default to Bolt. If you want to change this, you have to define the property ogm.properties when calling Maven. e.g. ./mvnw clean verify -Dogm.properties=ogm-bolt.properties.

For testing we are using TestContainers. The default image right now is neo4j:5. If you want to use other images or the enterprise edition, you have to opt-in.

Here is a list of the possible environment variables you can provide.

Variable Description Default value

NEO4J_OGM_NEO4J_ACCEPT_AND_USE_COMMERCIAL_EDITION

Use enterprise edition and accept the Neo4j licence agreement.

no

NEO4J_OGM_NEO4J_IMAGE_NAME

Image to be used by TestContainers.

neo4j:5

License

Neo4j-OGM and it’s modules are licensed under the Apache License v 2.0.

The only exception is the neo4j-embedded-driver which is GPL v3 due to the direct use of the Neo4j Java API.

More Repositories

1

neo4j

Graphs for Everyone
Java
12,473
star
2

NaLLM

Repository for the NaLLM project
TypeScript
952
star
3

neo4j-python-driver

Neo4j Bolt driver for Python
Python
864
star
4

neo4j-javascript-driver

Neo4j Bolt driver for JavaScript
JavaScript
832
star
5

neo4j-browser

Neo4j Browser is the general purpose user interface for working with Neo4j. Query, visualize, administrate and monitor the database.
TypeScript
651
star
6

graph-data-science

Source code for the Neo4j Graph Data Science library of graph algorithms.
Java
581
star
7

graphql

A GraphQL to Cypher query execution layer for Neo4j and JavaScript GraphQL implementations.
TypeScript
485
star
8

neo4j-go-driver

Neo4j Bolt Driver for Go
Go
476
star
9

neo4j-java-driver

Neo4j Bolt driver for Java
Java
322
star
10

docker-neo4j

Docker Images for the Neo4j Graph Database
Shell
307
star
11

neo4j-dotnet-driver

Neo4j Bolt driver for .NET
C#
218
star
12

graph-data-science-client

A Python client for the Neo4j Graph Data Science (GDS) library
Python
168
star
13

neo4j-jdbc

Official Neo4j JDBC Driver
Java
124
star
14

neo4j-documentation

Scala
99
star
15

trillion-graph

A scale demo of Neo4j Fabric spanning up to 1129 machines/shards running a 100TB (LDBC) dataset with 1.2tn nodes and relationships.
Java
89
star
16

cypher-shell

Cypher Shell has moved to https://github.com/neo4j/neo4j
Java
88
star
17

docker-neo4j-publish

Shell
82
star
18

sdn-rx

Nextgen Spring Data module for Neo4j supporting (not only) reactive data access and immutable support
Java
66
star
19

apoc

Java
63
star
20

helm-charts

Go
51
star
21

cypher-editor

Codemirror editor for Cypher, with syntax awareness and auto-completion
JavaScript
41
star
22

cypher-builder

A programmatic API for building Cypher queries for Neo4j.
TypeScript
35
star
23

neo4j-java-driver-spring-boot-starter

Automatic configuration of Neo4j's Java Driver for Spring Boot applications
Java
35
star
24

cypher-language-support

Neo4j's Cypher Language support
TypeScript
24
star
25

neo4j-example-auth-plugins

Example authentication and authorization plugins for Neo4j
Java
17
star
26

graphql-tracker-temp

This is a temporary repository for documentation and tracking issues for the @neo4j/graphql package until that repo is made public
12
star
27

graph-schema-introspector

This is a Proof of concept (PoC) for a Neo4j schema introspector that produces output in JSON format validating against graph-schema-json-js-utils.
Java
11
star
28

neo4j-ogm-quarkus

Quarkus extension to that allows proper usage of Neo4j-OGM inside Quarkus.
Java
10
star
29

docs-drivers

Neo4j Drivers Documentation
HTML
8
star
30

windows-wrapper

A service wrapper for windows
Java
8
star
31

neo4j.github.com

Web published resources
HTML
7
star
32

docs-cypher

Neo4j Cypher Documentation
JavaScript
7
star
33

docs-bolt

Neo4j Bolt Protocol Documentation
JavaScript
6
star
34

jsr311-api

Forked from revision 612
Java
6
star
35

dappr

Distributed Approximate Personalised PageRank
Jupyter Notebook
5
star
36

doctools

Perl
5
star
37

github-action-traceability

TypeScript
4
star
38

graph-schema-json-js-utils

Utility library to work with the Graph Schema JSON representation
TypeScript
4
star
39

parents

Neo4j Build Configuration
4
star
40

docs-operations

Neo4j Operations documentation
JavaScript
3
star
41

docs-getting-started

JavaScript
3
star
42

docs-http-api

Documentation for Neo4j HTTP API
JavaScript
3
star
43

neo4j-aws-terraform

HCL
3
star
44

jbang-catalog

JBang catalog
Java
2
star
45

graphql-toolbox

TypeScript
2
star
46

import-spec

Java
2
star
47

docs-graphql

GraphQL docs
JavaScript
2
star
48

docs-maven-plugin

Java
2
star
49

ease-maven-plugin

Java
2
star
50

license-maven-plugin

Fork of http://code.google.com/p/maven-license-plugin/
Java
2
star
51

docs-status-codes

Documentation for Neo4j status codes
JavaScript
2
star
52

maven-skin

Neo4j Maven Skin
Java
2
star
53

docs-aura

Jupyter Notebook
2
star
54

azure-neo4j

Azure topology files
Shell
1
star
55

clirr-maven-plugin

Java
1
star
56

neo4jtester

neo4j tester
Go
1
star
57

docs-ops-manager

JavaScript
1
star