Skip to content
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

ListProxy Lists are not sortable #160

Open
Restage opened this issue Jan 12, 2015 · 1 comment
Open

ListProxy Lists are not sortable #160

Restage opened this issue Jan 12, 2015 · 1 comment
Assignees
Labels
Milestone

Comments

@Restage
Copy link

Restage commented Jan 12, 2015

ListProxy Lists returned by fetching nodes via a node's relationship property are not sortable by calling Collection.sort(). That's because the set() method in the ListProxy is not yet implemented.
Is this on purpose or just an incomplete implementation at this point in time? Personally I would prefer to sort the list in my application logic rather then querying the nodes in a specific order.

Small Example Code:

List<IEvent> eventNodes = matchdayNode.getEvents();
eventNodes.sort(new EventComparator());
@DirkMahler DirkMahler added this to the 0.5.0 milestone Feb 27, 2015
@DirkMahler DirkMahler self-assigned this Feb 27, 2015
@DirkMahler
Copy link
Member

This behavior is on purpose - the returned List directly delegates to an iterator provided by the datastore (i.e. Neo4j). This allows large results to be returned.
If you need ordering you shoudl consider creating an active property with a cypher query e.g.:

@Label("MatchDay")
public interface MatchDay {

  List<Event> getEvents();

  @ResultOf
  @Cypher("match (m:MatchDay)-[:HAS_EVENT]->(e:Event) where id(m)={this} return e order by e.date") 
  Result<Event> getOrderedEvents();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants