OGM @Relationship ordered mapping

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!

Currently Neo4j-OGM does not keep the order of a sortable type. There is an issue (@Relationship (type = "...") ArrayList<T> does not maintain list sequence. · Issue #386 · neo4j/neo4j-ogm · GitHub) 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: Reference - OGM Library

1 Like

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