0

I've started to use Neo4j-ogm inside my application and it works like charm for fixed object domain model. When I know which node type connected to another node with known type - it can be easily mapped. However, in my opinion versitality of Neo4j graph database is also in an ability to work with un-typed (or dynamic) domain models and I'm having conceptual problem to understand how to achieve it with Neo4j-ogm.

Let me describe my problem with an example.

I have domain objects like: Message and Feature. Where Message can have multiple features and a Feature can be a part of many messages. It is completely ok to map with Neo4j-ogm.

Then what if user want to relate the message to some Task node type or refer it to some Contact node type ? In my application it is possible to have large (but limited) set of connection between nodes of various types. So I would like to be able to get all types of connections from a particular node, regardless of this connection types or endNode types?

Of course I can use cypher to create connections like this:

MATCH ($2911) WHERE id($2911)={$2911} MATCH ($2912) WHERE id($2912)={$2912} MERGE ($2911)-[_0:`part_of` {$aid} ]->($2912) RETURN id(_0) AS _0

but when I'm starting doing this - I would need a way how to convert results of this queries to and from relational entities myself.

Is there a gracefull way to do this using Neo4j-ogm. May be it is possible to create a comprehansive type heirarchy or something which will allow to use Neo4j-ogm together for fixed and dynamic domain object models.

Thank you in advance.

Luanne
  • 19,145
  • 1
  • 39
  • 51
Vladimir
  • 31
  • 3

1 Answers1

0

A fixed type hierarchy is supported by Neo4j OGM so if you are able to represent your domain in such a hierarchy, you should be able to fetch all connections from a single entity. This means that the end nodes must be also represented in this hierarchy.

Run time polymorphism is not supported in the current version- it's up for discussion though, so depending on how it goes, it might make it to a future release.

Luanne
  • 19,145
  • 1
  • 39
  • 51
  • Thanks for your answer. Nevertheless I've decided to stick with Neo4j-ogm such it is very nice library and much more advanced that mine tool to accessing Neo4j. In order to solve my problem with fixed domain, I'm planning to use Cypher queries to get un-mapped connections from any node. – Vladimir Nov 30 '15 at 08:30