1
I’m developing my first java application, desktop application with Netbeans and Hibernate.
I have the tables membros
and estadocivil
. The member has a marital status. I mapped the classes using Hibernate and in the class Members he created the attribute EstadoCivil
. My select on Hibernate is
from membros mb join mb.EstadoCivil"
My problem is that a list of objects is being returned, not members, and I can’t recover the data. How to return a Members list or convert Object to Members? Below is the code:
public List Select() {
List lista = new ArrayList();
try {
this.sessao = Sessao.getSessao();
transacao = sessao.beginTransaction();
query = sessao.createQuery("from Membros");
lista = query.list();
sessao.close();
} catch (HibernateException e) {
JOptionPane.showMessageDialog(null, "Erro ao realizar consulta!\n" +
e.getMessage(), null, JOptionPane.ERROR_MESSAGE);
}
return lista;
}