Announcement Announcement Module
No announcement yet.
Spring Data Graph - How do you relate your node entity to the graph's reference node? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Data Graph - How do you relate your node entity to the graph's reference node?

    I have not encountered any mention of the graph's reference or root node in any documentation or posts in this forum. Is it not significant? Are people not using it? I need to create node entities representing concept collections in my application directly related to the reference node so that when I use Neoclipse, I can drill down from the root node and not have to search for nodes using indexes. Is there a straightforward way to get a reference to the root node via annotations or arguments to the relatedTo annotation. Is this in the works?

  • #2
    You can use a different typeRepresentationStrategy (SubReferenceNodeTypeRepresentationStrategy) to represent your java types as hierarchy of nodes which then link to the instances.

    If you want to relate entites manually to the root node you could create a NodeEntity for the root node, something like:

    public class Root {
    public Root(Node rootNode) {

    and then in your entity classes use:

    class SomeCollection {
    RootNode root;

    you can assign the root node to this field on entity creation, e.g. in your constructor.

    I could imagine having something like that added to SDG, don't know what kind of API would be sensible, either an attribute on the NodeEntity annotation or a @RootNode annotation for a entity property.

    Problem of providing a "RootNode" class is that you probably have your own set of properties on the root which should be accessible via this entity.

    This also highlights one missing feature in SDG - listeners for lifecycle events (creation, loading, deleting, changing entities).