OGM @Relationship ordered mapping


(Jiropole) #1

When it comes to how the OGM maps query results to @Relationship List properties, is it expected that the result order should be retained in the list?

I’m ordering the results by a property order on the respective relationship. The raw results comes back in expected order, but the List property on my POJO is mapped out of order. Note I'm using Kotlin:

@Relationship(type = "ALONG", direction = Relationship.OUTGOING)
                 var axes: List<Axis>? = null

Can't really find much info on this topic – thanks!


(Gerrit Meier) #2

Currently Neo4j-OGM does not keep the order of a sortable type. There is an issue (https://github.com/neo4j/neo4j-ogm/issues/386) I also commented and tried to solve. It may get back in focus when we do a 4.0 version in the future but nothing I see in any upcoming minor version right now.

If your entities have something like a computable sort order you can achieve this in your application code: https://neo4j.com/docs/ogm-manual/current/reference/#_ordering


(Jiropole) #3

Thanks, after digging through various issues I realized this is fully documented exactly where it should be! Thanks again :slight_smile:
https://docs.spring.io/spring-data/neo4j/docs/current/reference/html/#_ordering