Hi there. I'll try to explain my context.
I have a Pattern entity, a Creation entity. Creations concerns a Pattern. Creation can have some Images. A Pattern can be represented by an Image.
Structure is like :
Pattern {
...
Image imgRepresent;
}
Creation {
...
Pattern pattern;
Collection<Image> images;
}
Image {
Creation creation
}
I need to fetch an Image by its id, and also fetch the Creation related to it, the Pattern related to this Creation, and the imgRepresent (the Image that represent this Pattern).
My query :
MATCH (v:Image {id: {id}})-[b:BELONG_CREATION]-(p:Creation)-[c:CREA_CONCERNS_PATTERN]-(pa:Pattern) "
+ "OPTIONAL MATCH (pa)-[e:IMAGE_REPRESENTS]-(i:Image) "
+ "return v, b, p, c, pa, i"
Optional<Image> findCustById(String id);
Then on java side i'm supposed to be able to do :
Image img = repo.findCustById(123).get();
img .getCreation().getPattern().getImgRepresent()
Unfortunately repo.findCustById(123) throws the error " Incorrect result size: expected at most 1".
I've changed the return type to
List< Image > findCustById(String id);
to see what's returned, and indeed I have 2 Image objects, the one with the id 123, but also the one which is in Pattern.imgRepresent.
Is there a solution here to only get the Image corresponding to the filter id=123, and the nested Image only in Pattern, and not in resultset?
Thx