I'm developing my first application in java, desktop application with Netbeans and hibernate.
I have tables membros
and estadocivil
. The member has a marital status. I mapped the classes using Hibernate and in the Members class it created the EstadoCivil
attribute. My select in hibernate is
from membros mb join mb.EstadoCivil"
My problem is that a list of objects is being returned, not members, and I can not retrieve the data. How do I return a list of Members or convert the object to Members? Here 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;
}