org.neo4j:neo4j-ogm-drivers

Annotation based Object Graph Mapper for Neo4j Server with Repository and Conversion support

License

License

Categories

Categories

Neo4J Data Databases
GroupId

GroupId

org.neo4j
ArtifactId

ArtifactId

neo4j-ogm-drivers
Last Version

Last Version

2.0.0-M02
Release Date

Release Date

Type

Type

jar
Description

Description

Annotation based Object Graph Mapper for Neo4j Server with Repository and Conversion support
Project Organization

Project Organization

Neo Technology, Inc.

Download neo4j-ogm-drivers

How to add to project

<!-- https://jarcasting.com/artifacts/org.neo4j/neo4j-ogm-drivers/ -->
<dependency>
    <groupId>org.neo4j</groupId>
    <artifactId>neo4j-ogm-drivers</artifactId>
    <version>2.0.0-M02</version>
</dependency>
// https://jarcasting.com/artifacts/org.neo4j/neo4j-ogm-drivers/
implementation 'org.neo4j:neo4j-ogm-drivers:2.0.0-M02'
// https://jarcasting.com/artifacts/org.neo4j/neo4j-ogm-drivers/
implementation ("org.neo4j:neo4j-ogm-drivers:2.0.0-M02")
'org.neo4j:neo4j-ogm-drivers:jar:2.0.0-M02'
<dependency org="org.neo4j" name="neo4j-ogm-drivers" rev="2.0.0-M02">
  <artifact name="neo4j-ogm-drivers" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.neo4j', module='neo4j-ogm-drivers', version='2.0.0-M02')
)
libraryDependencies += "org.neo4j" % "neo4j-ogm-drivers" % "2.0.0-M02"
[org.neo4j/neo4j-ogm-drivers "2.0.0-M02"]

Dependencies

compile (5)

Group / Artifact Type Version
org.neo4j : neo4j-ogm-api jar 2.0.0-M02
org.neo4j : neo4j jar 2.3.2
org.neo4j.driver : neo4j-java-driver jar 1.0.0-M01
org.apache.httpcomponents : httpclient jar 4.3.6
commons-io : commons-io jar 2.4

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

Maven Central Slack stackoverflow

Neo4j-OGM - An Object Graph Mapping Library for Neo4j

Note
This is the development branch of Neo4j-OGM. Please have a look at the current supported versions and which combinations we recommend: Recommended versions.

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.

If you use Spring to build your applications be sure to check out Spring Data Neo4j.

Quick start

You can start coding with some simple templates, or just follow the little guide below!

Dependencies for Neo4j-OGM

Maven

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

<dependency> <!-- If you're using the HTTP driver -->
    <groupId>org.neo4j</groupId>
    <artifactId>neo4j-ogm-http-driver</artifactId>
    <version>3.2.20</version>
</dependency>

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

<dependency> <!-- If you're using the Embedded driver -->
    <groupId>org.neo4j</groupId>
    <artifactId>neo4j-ogm-embedded-driver</artifactId>
    <version>3.2.20</version>
</dependency>

Gradle

dependencies {
    compile 'org.neo4j:neo4j-ogm-core:3.2.20'
    compile 'org.neo4j:neo4j-ogm-http-driver:3.2.20'
    compile 'org.neo4j:neo4j-ogm-bolt-driver:3.2.20'
    compile 'org.neo4j:neo4j-ogm-embedded-driver:3.2.20'
}

Ivy

<dependency org="org.neo4j" name="neo4j-ogm-core" rev="3.2.20"/>
<dependency org="org.neo4j" name="neo4j-ogm-http-driver" rev="3.2.20"/>
<dependency org="org.neo4j" name="neo4j-ogm-bolt-driver" rev="3.2.20"/>
<dependency org="org.neo4j" name="neo4j-ogm-embedded-driver" rev="3.2.20"/>

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;

	@Relationship(type = "ACTS_IN", direction = Relationship.INCOMING)
	Set<Actor> actors = new HashSet<>();

	public Movie() {
	}

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

}

Configuration

The either configure 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.

Feel free to chat with us on the Neo4j-OGM Slack channel, and have a look to some examples like Neo4j-OGM University.

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-http.properties to use the HTTP transport. Possible values are ogm-bolt.properties, ogm-http.properties and ogm-embedded.properties.

For tests we are using TestContainers. The default image right now is neo4j:3.5.12. 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:3.5.12

If you are using embedded-based tests, the TestContainers values are ignored. To switch between various Neo4j versions for embedded, you have to select the right profile. neo4j-3.2 - neo4j-3.5 and neo4j-enterprise or neo4j-3.5-enterprise if you want to test against the enterprise versions.

YourKit profiler

We would like to thank YourKit for providing us a license for their product, which helps us to make OGM better.

yourkit

YourKit supports open source projects with its full-featured Java Profiler. YourKit, LLC is the creator of YourKit Java Profiler and YourKit .NET Profiler, innovative and intelligent tools for profiling Java and .NET applications.

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.

org.neo4j

Neo4j

Versions

Version
2.0.0-M02
2.0.0-M01