AdminSecaoForm form = new AdminSecaoForm();
SecaoDAO dao = new SecaoDAO();
List<Secao> listaDeSecoes = dao.findAll(Order.asc("nome"));
/**
* A principio o primeiro item da listagem eh um elemento em branco
*/
if (listaDeSecoes.isEmpty()) {
listaDeSecoes.add(new Secao());
}
Pois é, esse código está disparando a exceção:
java.lang.UnsupportedOperationException
at java.util.AbstractList.add(AbstractList.java:151)
at java.util.AbstractList.add(AbstractList.java:89)
at PACOTE.execute(CLASSE.java:39)
Tenta trocar essa “List<Secao” por uma “ArrayList” ou “LinkedList” … você não pode ter uma lista do tipo List, pois ela é uma interface…por iso a exceção.
[quote]
Class AbstractList
…
To implement a modifiable list, the programmer must additionally override the set(int index, Object element) method (which otherwise throws an UnsupportedOperationException. If the list is variable-size the programmer must additionally override the add(int index, Object element) and remove(int index) methods.[/quote]
Ou seja, a lista retornada pelo Hibernate é(ou era na época) imutável.