Skip to content

Mapping of nested classes collected under common label #2462

@marichka-spin

Description

@marichka-spin

Hello, team!

I have a question regarding inheritance again. For Example there is the following architecture:

@Getter
@Setter
@Node("Base")
public abstract class BaseClass {

    @Id
    private String uuid;
}

@Getter
@Setter
@Node("PetOwner")
public abstract class PetOwner extends BaseClass {

    private String name;

    @Relationship(type = "hasPet")
    private List<Animal> pets;
}

@Node("Boy")
public class Boy extends PetOwner {
}

@Node("Girl")
public class Girl extends PetOwner {
}

@Getter
@Setter
@Node("Animal")
public abstract class Animal extends BaseClass {

    private String name;
}

@Node("Cat")
public class Cat extends Animal {
}

@Node("Dog")
public class Dog extends Animal {
}

public interface BaseClassRepository extends Neo4jRepository<BaseClass, String> {
}

I have a use case when I need to get the collection of all entities that are subclassed from BaseClass. With OGM I was able to execute the following query and have everything mapped correctly.

MATCH (n:Base) RETURN n, [(n)-[r]->(b) | [r,b]]

But now the cypher response has increased significantly and not totally correct. It doesn't expect to cover even this simple inheritance scheme described in first code block.

Please take a look at my unit tests in the repository https://github.com/idun-corp/neo4j-test (Test PetOwnerNeo4jServiceTest.testGetAllWithRelations)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions