I have an error after closing Hibernate Session
public String listarTodosClientes() {
session.getTransaction().begin();
List<Cliente> lista = session.createCriteria(Cliente.class).list();
session.close();
return lista.toString();
}
After session.close (), the toString () method generates an Exception. But if I remove the session.close (). The code works. And now I can leave the session open?
p.s: return a string was just an example. could be returning some item from the list.