4 Replies Latest reply on Dec 19, 2006 9:51 AM by Owain Davies

    EJB QL requires useless item in select list

    Owain Davies Newbie

      I have the following EJB QL

      select r.channel.id, sum(se.currentListeners), r from Request r
      left join fetch r.channel c
      left join fetch r.stats s
      left join fetch s.statsEntries se
      where r.createdDate > :startDate and r.createdDate < :endDate
      group by r.channel

      i want to get rid of the r in the select list but it wont let me, can anyone tell me why? in normal sql i wouldnt need the r in the select list. The problem is it takes time to instantiate those Request objects and its totally wasted. I want it to look like this:

      select r.channel.id, sum(se.currentListeners) from Request r
      left join fetch r.channel c
      left join fetch r.stats s
      left join fetch s.statsEntries se
      where r.createdDate > :startDate and r.createdDate < :endDate
      group by r.channel

      lovely that would involve no wasted effort and speed up my query. Can anyone help me i dont understand why i need the r in the select list, is hibernate dumb?