Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to sort a List of objects by their date (java collections, List<Object>)
    primarykey
    data
    text
    <pre><code>private List&lt;Movie&gt; movieItems = null; public List&lt;Movie&gt; getMovieItems() { final int first = 0; if (movieItems == null) { getPagingInfo(); movieItems = jpaController.findRange(new int[]{pagingInfo.getFirstItem(), pagingInfo.getFirstItem() + pagingInfo.getBatchSize()}); Collections.sort(movieItems, new Comparator(){ public int compare (Object o1, Object o2){ Date d1 = movieItems.get(((Movie)o1).getMovieId()).getDate(); Date d2 = movieItems.get(((Movie)o2).getMovieId()).getDate(); if(d1.before(d2)){ movieItems.set(1, (Movie)o1); movieItems.set(2, (Movie)o2); } return first; } }); } return movieItems; } </code></pre> <p>jpaController is bringing back 4 movies and is giving me the following</p> <blockquote> <p>java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 4 at java.util.Vector.get(Vector.java:694) at entitybeans.jsf.PeliculaController$1.compare(PeliculaController.java:260) at java.util.Arrays.mergeSort(Arrays.java:1270) at java.util.Arrays.sort(Arrays.java:1210) at java.util.Collections.sort(Collections.java:159) at entitybeans.jsf.PeliculaController.getPeliculaItems(PeliculaController.java:257) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at javax.el.BeanELResolver.getValue(BeanELResolver.java:302) at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:175) at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72) at com.sun.el.parser.AstValue.getValue(AstValue.java:116) at com.sun.el.parser.AstValue.getValue(AstValue.java:163)....</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload