-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: display data from an "inner join" correctly
PostPosted: Thu Mar 14, 2013 11:00 pm 
Newbie

Joined: Thu Mar 14, 2013 10:23 pm
Posts: 2
I have the following query in HQL:

Two tables (Citations and related DetalleCita one to many)

"select c from Cita c inner join c.detalleCitas d where d.dcFecha = '2013-03-12 00:0:00 '"

but when I retrieve the list of quotes I recovered all of appointment details and when should I just mostra a detail which is the date of the query.

seems it did not work the inner join to do and shows me:

appointment 1
cita1.detalle 1
cita1.detalle 2
cita1.detalle 3

should show:

cita1
cita1.detalle3

Can you help me?


Top
 Profile  
 
 Post subject: Re: display data from an "inner join" correctly
PostPosted: Tue Mar 19, 2013 7:58 am 
Newbie

Joined: Thu Mar 22, 2012 7:43 am
Posts: 3
i have the same issue here.. please post here if you have answered this.


Top
 Profile  
 
 Post subject: Re: display data from an "inner join" correctly
PostPosted: Tue Mar 19, 2013 9:51 am 
Newbie

Joined: Thu Mar 14, 2013 10:23 pm
Posts: 2
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.