Announcement Announcement Module
Collapse
No announcement yet.
Inheritance in spring data graph Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Inheritance in spring data graph

    Hi
    is inheritance supported in the data graph framework?
    How it can be modelled efficiently?
    can i do polymorphic queries?
    thanks
    Joe

  • #2
    Joe,

    can you give a concrete example for the domain and the polymorphic queries you're asking for?

    Inheritance is supported directly, the @NodeEntity and @RelationshipEntity are both @Inherited annotations.

    As the graph database is schema-free all the properties are stored directly at the node, no need for superclass nodes.

    The type information is stored via a TypeRepresentationStrategy (either via indexing or a hierarchy of nodes representing the type hierarchy).

    For polymorphic access you can for instance create repositories of superclasses and access different subtypes via their supertype.

    repository = graphRepositoryFactory.createGraphRepository(Super type.class);
    Iterable<SuperType> result = repository.findAll();

    this is also possible for relationship-fields

    @RelatedTo(elementClass = "SuperType.class", type = "RELATED_TO")
    Set<Supertype> things;

    the set then contains instances of different subtypes.

    Another very important ability of SDG is the projection ability.

    You can project any entity to any other entity with no restrictions.

    e.g.

    Employee employee = person.projectTo(Employee.class);

    HTH

    Michael

    Comment

    Working...
    X