GithubHelp home page GithubHelp logo

sslcmy / neo4j-ogm Goto Github PK

View Code? Open in Web Editor NEW

This project forked from neo4j/neo4j-ogm

0.0 1.0 0.0 7.86 MB

Java Object-Graph Mapping Library for Neo4j

Home Page: https://neo4j.com/developer/neo4j-ogm

License: Apache License 2.0

Java 99.84% Shell 0.16%

neo4j-ogm's Introduction

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.

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

The latest OGM version is: 2.1.2. The latest OGM development version is: 2.1.3-SNAPSHOT and 3.0.0-SNAPSHOT.

Quick start

Dependencies for Neo4j OGM

Maven

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

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

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

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

Gradle

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

Ivy

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

Set up domain entities

@NodeEntity
public class Actor {

	@GraphId
	private Long id;
	private String name;

	@Relationship(type = "ACTS_IN", direction = "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 {

	@GraphId
	private Long id;
	private String title;
	private int released;

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

	public Movie() {
	}

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

}

Configuration

The OGM can be configured in two ways. The easiest is auto configuration, where ogm.properties must be on the root of the classpath. The other is via Java configuration.

Please see examples here

Persist/Load entities

//Set up the Session
SessionFactory sessionFactory = new SessionFactory("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.

Neo4j-OGM University, the sample application shown in the reference guide is a working example of a Groovy/Ratpack app that uses the Neo4j OGM library (with the Bolt driver). A version that uses the Embedded driver is also available as well as a version that uses the HTTP driver.

Building locally

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

YourKit profiler

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

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.

neo4j-ogm's People

Contributors

atg103 avatar benataim avatar ceefour avatar frant-hartm avatar jasperblues avatar jdorleans avatar jexp avatar jimwebber avatar jjaderberg avatar lassewesth avatar luanne avatar mangrish avatar mihairaulea avatar nd0 avatar nmervaillie avatar odedsh avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.