-
Notifications
You must be signed in to change notification settings - Fork 618
Closed
Closed
Copy link
Labels
status: waiting-for-triageAn issue we've not yet triagedAn issue we've not yet triaged
Milestone
Description
Hello,
I'm getting a StackOverflowException when executing a custom query and whent the result contains circular references.
I'm having this issue with SDN 6.2.3 (and 6.1.10).
I didn't have this issue in 6.1.5.
Since SDN works record-oriented I would expected to have some lines with duplicated entity instances (different instances, but same data), but I wouldn't have expected the stackOverflowException.
My entites:
@Node(labels = "Type")
public class Type {
@Id
@GeneratedValue
private Long id;
private String code;
@Relationship(type = "IS_ALLOWED")
private List<Type> allowed = new ArrayList<>();
// getters/setters ommited
}
My repository:
@Repository
public interface TypeRepository extends Neo4jRepository<Type, Long> {
@Query("MATCH (nt:Type)\n"
+ "OPTIONAL MATCH (nt)-[raut:IS_ALLOWED]->(aut)\n"
+ "RETURN nt,\n"
+ " collect(raut), collect(aut)\n"
)
List<Type> findAllTypes();
}
And my unit test reproducing the error:
@Test
void findWithCircularReferenceThrowsStackOverflowException() {
Type formation = new Type().code("FORMATION");
Type groupement = new Type().code("GROUPEMENT");
formation.allowed(groupement);
groupement.allowed(groupement);
List<Type> toSave = List.of(
formation,
groupement
);
repository.saveAll(toSave);
List<Type> types = repository.findAllTypes();
assertThat(types).isNotEmpty();
}
The unit test is also available here: https://github.com/gonzalad/sdn-circular-references-stackoverflow/blob/master/src/test/java/com/example/sdncircularreferencesstackoverflow/SdnTest.java
Thanks for your help !
Metadata
Metadata
Assignees
Labels
status: waiting-for-triageAn issue we've not yet triagedAn issue we've not yet triaged