Well, I did not find a solution, but in my case I need to return a List of objects, which do not require that all my tables are related.
so what I did was this:
Code:
public List<Object[]> citasxFecha(Date sqlDate) {
try{
Session session = HibernateUtil.getSessionFactory().openSession();
//Query query = session.createQuery("select c from Cita c inner join c.detalleCitas d where d.dcFecha=:fecha");
Query query = session.createQuery("select " +
"d.dcHora," +
"d.dcEstado," +
"t.tipoEvaNombre," +
"d.dcSala," +
"c.ccCv," +
"c.empCodigo," +
"e.empNombre," +
"c.ccPuesto," +
"em.emAbrev," +
"c.emCodigo," +
"c.conCodigo," +
"d.dcObs " +
"from " +
"Cita c inner join c.detalleCitas d," +
"TipoEvaluacion t," +
"Empresa e," +
"Empleados em " +
"where " +
"d.dcFecha=:fecha and " +
"c.empCodigo = e.empCodigo and " +
"c.emCodigo = em.emCodigo and " +
"c.tipoEvaCodigo = t.tipoEvaCodigo and " +
"d.emCodigo = em.emCodigo");
query.setDate("fecha", sqlDate);
List<Object[]> lista = query.list();
return lista;
}catch(Exception e)
{
System.out.println("Error al realizar el query : " + e.getMessage());
}finally{
if (session != null && session.isOpen())
{
session.close();
}
}
return null;
}
As you will notice in the query on multiple tables but are not all related, because I do not want to do a cascade delete when deleted.