Skip to content

BeanInstantiationException with @DynamicLabels and multiple levels of inheritance #2529

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cberes opened this issue Apr 28, 2022 · 2 comments
Assignees
Labels
type: bug A general bug

Comments

@cberes
Copy link
Contributor

cberes commented Apr 28, 2022

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.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Apr 28, 2022
@meistermeier meistermeier self-assigned this May 1, 2022
@meistermeier
Copy link
Collaborator

Thanks for reporting this and providing the nice to follow reproducer. Already the first run seems to uncover that there might be an error in the processing of the labels from the database if a dynamic label is involved.

@meistermeier meistermeier added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels May 1, 2022
@meistermeier meistermeier added this to the 6.2.5 (2021.1.5) milestone May 3, 2022
@meistermeier
Copy link
Collaborator

It will be fixed in the upcoming versions. You could give the 6.2.5-SNAPSHOT a try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

3 participants