I was trying to query my node Person by its internal ID and the code of its City like this: Optional<Person> findByIdAndCityCode(Long id, String cityCode);
but the generated query behind this tries to access the ID as a property, like this:
MATCH (n:`Person`)-[r_1:`LOCATED_IN`]->(m_1:`City`) WHERE (n.id= $0 AND m_1.code = $1) RETURN n
instead of going for id(n)=$0, which is what I need in this scenario.
How can I solve this issue without writing a custom query for every such case where I have to search by the internal ID and another property? findById works just find by its own, but when trying to add more properties to the query it gets weird.
Should I consider adding another id field that I can query on?
findbyId uses the natural Id key (primary key) value as query parameter not internal ID's. None of the SDN repositories work like that, not just Neo4J data ones.
I was referring to this ID regarding the "internal ID", Person node inside my DB:
while in my Node Java fila I have:
@Id
@GeneratedValue
private Long id;
findById queries by that ID correctly -> id(person) = $0, while the personRepository.findByIdAndCityCode goes for person.id = $0 AND city.code = $1 instead of id(person) = $0 AND city.code = $1, which results to an error, because <id> is not a property of the node.
Is that expected behavior?