Results 1 to 2 of 2

Thread: Inheritance in spring data graph

  1. #1
    Join Date
    May 2008
    Posts
    227

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

    Default

    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

Posting Permissions

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