Results 1 to 2 of 2

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

  1. #1
    Join Date
    May 2010
    Posts
    6

    Default 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. #2
    Join Date
    Jan 2011
    Location
    Dresden, Germany
    Posts
    525

    Default

    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:

    @NodeEntity
    public class Root {
    public Root(Node rootNode) {
    setPersistentState(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).

    Cheers

    Michael

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •