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

LazyList and Collections.sort() and Collections.reverse() behavior #34

Open
helloariel opened this issue Nov 15, 2013 · 2 comments
Open

Comments

@helloariel
Copy link

Hi there,

I'm getting very inconsistent and buggy behavior when calling Collections.sort() and Collections.reverse() on the LazyLists returned by query.getResultList(). Basically, the lists are sometimes properly sorted and reversed and sometimes they are half sorted, not sorted in the right order, etc.

I couldn't narrow down the issue precisely but I assume it happens if the LazyList isn't fully populated. Couple questions:

  • Is there anyway to force the lazylist to be populated, or disable lazy loading altogether?
  • Is there any precautions I need to take for these lazy list to behave as normal lists?

Thanks!

@treeder
Copy link
Member

treeder commented Nov 18, 2013

Probably best to iterate through the results (LazyList) and add them to another collection that supports all those functions.

@helloariel
Copy link
Author

That's what I ended up doing. Iterating through the list and adding them to an ArrayList. The behavior of LazyList seems very dangerous however. Maybe it doesn't fully comply with the specifications of the List interface?

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

No branches or pull requests

2 participants