Kasper
Kasper

Reputation: 141

Manually add NodeEntity, Id, GeneratedValue, RelationshipEntity etc (not using annotations)

I have two maven projects;

a) A REST Server project

b) A Rest consuming client project

I would like to make a 3rd project containing domain POJO classes - and add it as a dependency in the two other projects so I only have one project with the domain classes. However, the REST Server project is depended on org.neo4j.ogm which uses annotations to achieve graph persistence (@NodeEntity, @Id, @GeneratedValue, @RelationshipEntity etc.).

Clearly, I don't want the POJO project depended on anything, since it's going to be used by the client also. So my question is; can I add these settings manually somehow, not using the annotations?

Upvotes: 1

Views: 180

Answers (1)

meistermeier
meistermeier

Reputation: 8262

Neo4j-OGM only works with annotations and does not have for example XML-based declaration support.

It would be a little bit hacky and limited but there is one scenario this could work:

  • Entities without @NodeEntity annotation will get recognized as such if you use an auto-generated id as Long id (without @Id and @GeneratedValue annotation).
  • No @RelationshipEntity definitions.
  • All relationships are outgoing and their names should get derived from their field name. (e.g. List<User> friends would become something like (...)-[:FRIENDS]->(:User))
  • No use of other Neo4j-OGM annotations like @Property, @Convert, etc.

Upvotes: 1

Related Questions