Quarkus: Support Neo4j-OGM in the Neo4j extension

Created on 10 Apr 2020  Â·  13Comments  Â·  Source: quarkusio/quarkus

Description
The Neo4j Extension guide states that you need to use the Neo4j Cypher language to manipulate your Neo4j database. It would be nice if one could to simplify development with the Neo4j graph database and like JPA, using annotations on simple POJO domain objects.

That's the intention of the Neo4j-OGM project

Bonus points if a Panache extension is provided too.

Implementation ideas
Make the Neo4j extension depend on the neo4j-ogm libraries and allow injecting the corresponding SessionFactory/Session in CDI beans

areneo4j kinenhancement

Most helpful comment

While there actually people using OGM in CDI scenarios, it would definitely not work in native mode. Thinks that would be needed: A class index (probably Yandex), replacement for the reflection based entity instantiation and a couple of other things.

I’ll raise this in our team at least for discussion.

All 13 comments

/cc @michael-simons

While there actually people using OGM in CDI scenarios, it would definitely not work in native mode. Thinks that would be needed: A class index (probably Yandex), replacement for the reflection based entity instantiation and a couple of other things.

I’ll raise this in our team at least for discussion.

Hi,
some days ago, i started to play with neo4j-ogm. I have problems with classloader in dev mode (mvn compile quarkus:dev - neo4j-ogm don't see the java classes with @NodeEntity annotation). In test and in java mode (running java -jar target/xxx.jar) quarkus and neo4j-ogm work correctly.
I would like to investigate if I can identify the classes to be highlighted for reflection to have quarkus in native mode.
My test project: https://github.com/fiorenzino/neonq

As Michael beforementioned, you'd need to read from the Jandex index instead

Em Dom, 12 de abr de 2020 16:57, fiorenzo pizza notifications@github.com
escreveu:

Hi,
some days ago, i started to play with neo4j-ogm. I have problems with
classloader in dev mode (mvn compile quarkus:dev - neo4j-ogm don't see the
java classes with @NodeEntity annotation). In test and in java mode
(running java -jar target/xxx.jar) quarkus and neo4j-ogm work correctly.
I would like to investigate if I can identify the classes to be
highlighted for reflection to have quarkus in native mode.
My test project: https://github.com/fiorenzino/neonq

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/quarkusio/quarkus/issues/8530#issuecomment-612667956,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAANG5O42RAUBLQCPJAD5KLRMIMLDANCNFSM4MFSMPQA
.

HI @gastaldi
In a specific extension, at deployment stage, i understand (using Jandex, we could create a SessionFactory using jandex index, to find @NodeEntity java classes annotated, and also replace the native neo4j-OGM way to create a SessionFactory using a package parameter to read all entities). But in the simple java code, with neo4j-ogm jar dependency, why the class loader is different?
Why the SessionFactory don't watch the classes in the project?
What the difference between:

  • mvn quarkus:dev (here this not work)
    and
  • java -jar target/file.jar (here quarkus and neo4j-ogm work fine)

Huge +1 from me on this issue, having OGM would be nice.

Managed to get Quarkus working with OGM (manually, with only @Inject Driver driver being provided) and I run into the same problem as @fiorenzino, doesn't find my classes (Neo DomainInfo#create to be precise), it works in production JVM mode.

Why not use Hibernate OGM instead?

If you are familiar with Hibernate ORM and JPA, it is more friendly for developers.

@hantsy We try to be as friendly as possible :)

Not finding things in dev mode has luckily nothing todo with Graal Native:

@sdaschner @fiorenzino Would you please raise this as an issue with @lukehutch from https://github.com/classgraph/classgraph/? It seems we're playing through all the class loaders out there.

You can basically copy my reproducer from OpenLiberty from that issue: https://github.com/classgraph/classgraph/issues/414 The guts of it being:

import io.github.classgraph.ClassGraph;
import io.github.classgraph.ScanResult;

int numberOfClassesFound = 0;
        // The servlet itself should be found... But isnt.
        try (ScanResult r = new ClassGraph().verbose(true).enableRealtimeLogging().enableAllInfo().whitelistPackages("io.openliberty.guides.hello").scan()) {
            numberOfClassesFound = r.getAllClasses().size();
}

Just add a package with one empty class and see if it returns something

@fiorenzino @michael-simons Updating Neo4J OGM to 3.2.11 solved the dev mode issue for me, you might want to try that. However, you have to add the Neo4J driver 4.0.1 dependency (Quarkus includes 4.0.0):

<!-- required for Neo4J 3.2.11, Quarkus imports 4.0.0 -->
<dependency>
    <groupId>org.neo4j.driver</groupId>
    <artifactId>neo4j-java-driver</artifactId>
    <version>4.0.1</version>
</dependency>

@hantsy Seems that there is currently no plan to support Hibernate OGM: #6514

There's an open issue https://github.com/quarkusio/quarkus/pull/6265 I can bump the version number there…

The version is already upgraded.

While there actually people using OGM in CDI scenarios, it would definitely not work in native mode. Thinks that would be needed: A class index (probably Yandex), replacement for the reflection based entity instantiation and a couple of other things.

Correct, the Quarkus classloader is supported by ClassGraph, however ClassGraph cannot work with Quarkus in native mode, because there is no traditional classfile to read. However, there is some advice on the ClassGraph wiki on how to implement build-time scanning. Presumably the Neo4J-OGM plugin could do something like this, perhaps even in an automated way, to index classes, if the compiler is building a native project. (Is there any way to force GraalVM's partial evaluation to automatically turn run-time scanning directly into build-time scanning, by running the runtime scanning logic at build-time, and caching the result in the compiled binary? Maybe this is wishing for too much.)

@sdaschner @fiorenzino Would you please raise this as an issue with @lukehutch from https://github.com/classgraph/classgraph/? It seems we're playing through all the class loaders out there.

Sorry, can you please describe the issue?

OK: i can confirm, using latest version of neo4j libraries in quarkus 1.3.2.Final,
./mvnw quarkus:dev
works fine.

<quarkus.platform.version>1.3.2.Final</quarkus.platform.version> <neo4j-ogm-core.version>3.2.11</neo4j-ogm-core.version> <neo4j-ogm-bolt-driver.version>3.2.11</neo4j-ogm-bolt-driver.version> <neo4j-java-driver.version>4.0.1</neo4j-java-driver.version>
i will create a simple reproducer for quarkus problems in native mode.

Was this page helpful?
0 / 5 - 0 ratings