Skip to content

Would be nice to have @OrderBy on collection relationships [DATAGRAPH-1345] #1907

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
spring-projects-issues opened this issue Jul 27, 2020 · 1 comment
Assignees
Labels
status: declined A suggestion or change that we don't feel we should currently apply type: enhancement A general enhancement

Comments

@spring-projects-issues
Copy link

Gerrit Meier opened DATAGRAPH-1345 and commented

It would be nice to have @OrderBy annotation specifying the ordering of the elements of a @Relationship collection.

For example:

 

{{@OrderBy("firstName ASC, lastName ASC")
@Relationship("HAVE_USER")
private Set<User> users = new LinkedHashSet<>();}}

This would perform the ordering at the DB level by firstName then lastName with ASC. I know that we can do it programmatically with SortedSet but I guess DB level is a much more great way of doing this.

LinkedHashSet preserves order based on insertion order that is why I used that one


Affects: 6.0 M2 (2020.0.0)

Reference URL: neo4j/sdn-rx#227

@michael-simons
Copy link
Collaborator

Hi @aaramg while this is a quite relatable and good idea, we cannot implement it as such.
We do use a thing called List comprehensions to fetch the relationships. Those cannot be sorted inline and we would have to unroll them first after creating them, defeating their purpose.

My suggestion is implementing orderable on your domain object and using a sorted collection. We do reuse the collection type.

@michael-simons michael-simons added the status: declined A suggestion or change that we don't feel we should currently apply label May 18, 2021
michael-simons added a commit that referenced this issue May 18, 2021
See #1907. Not an implementation or a fix, but improvement of overall readability.
michael-simons added a commit that referenced this issue May 18, 2021
See #1907. Not an implementation or a fix, but improvement of overall readability.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: declined A suggestion or change that we don't feel we should currently apply type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants