why do i get a SEVERE: javax.el.ELException: /test.xhtml: For input string: "id"
Because a native query returns a List<Object[]>
, not a List<Test>
. You're basically attempting to access an Object[]
array using a string such as "id"
as index instead of an integer such as 0
. If you look closer to the stack trace, then you should have noticed the presence of ArrayELResolver
a little further in the stack after the exception, which should already have hinted that #{item}
is actually been interpreted as an array.
So, if you absolutely can't obtain it as a fullworthy List<Test>
(you can easily do inner joins using @ManyToOne
and so on), then this should do to obtain the first column from the SELECT
query:
<li>#{item[0]}</li>