-
Apr 30th, 2011, 05:17 PM
#1
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
-
May 1st, 2011, 02:53 AM
#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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules