Skip to content

Quarkus extension to that allows proper usage of Neo4j-OGM inside Quarkus.

License

Notifications You must be signed in to change notification settings

neo4j/neo4j-ogm-quarkus

Neo4j-OGM Quarkus Extension

This is an extension for Quarkus.io, depending on the official Quarkus Neo4j Extension. Neo4j-OGM Quarkus configures Neo4j-OGM to use the low-level connectivity provided by the Quarkus Neo4j extension.

badge badge

Introduction

This extension is meant to be used on top of Quarkus Neo4j Extension. It uses the driver provided with the latter to configure Neo4j-OGMs SessionFactory, so that you can get an instance in beans like this:

import java.util.Collection;

import jakarta.enterprise.context.ApplicationScoped;

import org.neo4j.ogm.session.SessionFactory;

@ApplicationScoped
public class MovieRepository {

	private final SessionFactory sessionFactory;

	MovieRepository(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}

	public Collection<Movie> findAll() {
		return sessionFactory.openSession().loadAll(Movie.class);
	}
}

In addition, it will take care that all classes annotated with @NodeEntity and @RelationshipEntity are discovered by Quarkus in both JVM and native mode.

Note
Please note that this extension only supports connections via the Bolt-protocol.

Downloads

Maven artifacts are available on central under the following coordinates: org.neo4j:neo4j-ogm-quarkus:3.9.0.

Note
There is no need to declare any other dependency (for Neo4j-OGM or Quarkus-Neo4j, this extension here brings both of them).

Include in a Maven build

<dependency>
    <groupId>org.neo4j</groupId>
    <artifactId>neo4j-ogm-quarkus</artifactId>
    <version>3.9.0</version>
</dependency>

Include in a Gradle build

dependencies {
    implementation 'org.neo4j:neo4j-ogm-quarkus:3.9.0'
}

Manual

The underlying Neo4j-Driver extension is documented in the Quarkiverse: Quarkus Neo4j. The Neo4j-OGM manual is here.

There is little to be configured in this extension itself apart from a few properties:

Configuration property

Type

Default

🔒 org.neo4j.ogm.base-packages

An optional list of packages to scan. If empty, all classes annotated with org.neo4j.ogm.annotation.NodeEntity @NodeEntity or org.neo4j.ogm.annotation.RelationshipEntity @RelationshipEntity will be added to the index.

list of string

org.neo4j.ogm.use-native-types

Should Neo4j native types be used for dates, times and similar?

boolean

false

org.neo4j.ogm.use-strict-querying

This flag instructs OGM to use all static labels when querying domain objects.

boolean

false

org.neo4j.ogm.database

The database that should be used (Neo4j EE 4.0+ only). Leave empty for using the default database.

string

🔒 Configuration property fixed at build time - All other configuration properties are overridable at runtime

Dependencies

The integration-tests module is a good candidate for showing how the dependencies flow in the Neo4j-Quarkus ecosystem:

dependencies

quarkus-neo4j - the official Quarkiverse extension - sits in the middle. It provides the neo4j-java-driver, the essential connectivity. Depending on it are neo4j-ogm-quarkus (this project) and inside the integration tests, neo4j-migration-quarkus which runs the Cypher-scripts with our test data for us. neo4j-ogm-quarkus brings the necessary dependencies for Neo4j-OGM itself, and of course, contains all the Quarkus "magic" to make things work nicely together.