Closed
Description
Spring Boot: 2.4.2
I have the following Model:
@Node
public class Country {
private String code;
@Relationship(type="HAS_CURRENCY", direction = Relationship.Direction.OUTGOING)
private Set<Currency> currencies = new HashSet<>();
}
Note: A HAS_CURRENCY example: (Country) - [HAS CURRENCY] -> (Currency)
@Node
public class Currency {
private String name;
}
@Repository
public interface CountryRepository extends Neo4jRepository<Country, Long> {
Optional<Country> findByCode(String code);
}
If I do countryRepository.findByCode("CODE"), Spring Data executes the following query
MATCH (n:`Country`)
WHERE n.code = "ES"
RETURN n{ .code,
__nodeLabels__: labels(n),
__internalNeo4jId__: id(n),
__paths__: [p = (n)-[:`HAS_CURRENCY`]->()-[:`HAS_CURRENCY`*0..]-() | p]}
Expected Behavior:
I expect countryRepository.findByCode("CODE") to return the Country with the given "CODE" and its Currencies.
Actual Behavior:
The actual behavior is that Spring Data Neo4j tries to load the whole graph. I think that is because when Spring Data generates the query, it won't add the direction in the second depth level.
How it is:
__paths__: [p = (n)-[:`HAS_CURRENCY`]->()-[:`HAS_CURRENCY`*0..]-() | p]}
How it should be:
__paths__: [p = (n)-[:`HAS_CURRENCY`]->()-[:`HAS_CURRENCY`*0..]->() | p]}
Metadata
Metadata
Assignees
Labels
No labels