OGM: Issues with polymorphism and @Relationship collections

(Martin Folke Emdal) #1

I have been struggling for a while to use the ogm-driver to load relationships of collections of child classes.

    @Relationship(type = "HAS_INGREDIENT")
    Set<Ingredient> ingredients;

When instantiated to contain some objects that inherit from Ingredient, those child objects relationships won't load.

public class Strawberry extends Ingredient {

    @Relationship(type = "TASTES_LIKE")
    Flavor flavor;

public class Ice extends Ingredient {

    @Relationship(type = "HAS_TEMPERATURE")
    Temperature temperature;

The properties and labels of the Ice/Strawberry nodes load just fine from the graph, but not their relationships. Is there a way to make this work?
Example project: