I am using a nativequery to get the row numbers. However this will return an Object array to me. This gives me a:
SEVERE: Servlet.service() for servlet [Faces Servlet] in context with path [/BowlingInfo] threw exception [For input string: "position"] with root cause
java.lang.NumberFormatException: For input string: "position"
In the case of the normal createQuery it will correctly return "Hallmaster" classes to me and it will execute correctly in my primefaces xhtml.
listHallmastaren = (List<Hallmaster>) em.createNativeQuery("SELECT id, @rownum := @rownum + 1 AS position, e.name, e.score FROM HALLMASTER e, (SELECT @rownum:=0) t ORDER BY e.score desc").getResultList();
listHallmastaren = em.createQuery("select e from Hallmaster e").getResultList();
To correctly coerse the native query back to the class you expect you need to tell the query to return types of that class. Note the , Hallmaster.class at the end.
listHallmastaren = (List<Hallmaster>) em.createNativeQuery("SELECT id, @rownum := @rownum + 1 AS position, " +
" e.name, e.score FROM HALLMASTER e, (SELECT @rownum:=0) t ORDER BY e.score desc", Hallmaster.class).getResultList();