cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

OGM @Relationship ordered mapping

Jiropole
Graph Voyager

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!

1 ACCEPTED SOLUTION

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

View solution in original post

2 REPLIES 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

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