Skip to content

BeanInstantiationException with @DynamicLabels and multiple levels of inheritance #2529

@cberes

Description

@cberes

SDN 6.2.4 is unable to instantiate nodes with multiple levels of inheritance and a non-empty @DynamicLabels field.

I have an example repo but here is a summary of the problem.

For example, say you have a super class

@Getter
@Node
public abstract class Animal {
  @DynamicLabels
  private Set<String> labels = new TreeSet<>();
}

A sub class

@Node
public abstract class Feline extends Animal {
}

And a sub class of the sub class

@Node
public class Cat extends Feline {
}

You can query for instances of the Cat sub class only if they do not have a dynamic label

Cat cat1 = new Cat();
animalRepository.save(cat1);

Cat cat2 = new Cat();
cat2.getLabels().add("Orange");
animalRepository.save(cat2);

Cat found1 = (Cat) animalRepository.findById(cat1.getId()).get(); // this is fine
Cat found2 = (Cat) animalRepository.findById(cat2.getId()).get(); // BeanInstantiationException

The second query fails if the Feline sub class is abstract or concrete, though the exception is different.

This example worked correctly in SDN 6.2.1 but it fails with SDN 6.2.4.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions