0

Executing JPQL using hibernate 4.2.5:

select c from Chargeback as cc join cc.customer as c group by c order by max(cc.created)

Usecase: show customers with the latest chargbacks.

produces org.hibernate.exception.SQLGrammarException: could not extract ResultSet

  1. When using select c.id from Chargeback as cc join cc.customer as c group by c order by max(cc.created) it will work.
  2. When using select c from Chargeback as cc join cc.customer as c group by c.id, c......all columns order by max(cc.created)

Is it a bug? why JPQL does not include *? (from this usecase it is very necessary)

NO need - native sql of course to solve it. We assume JPQL is mature.

kadkaz
  • 123
  • 2
  • 7

1 Answers1

0

There is a feature request for this: HHH-1615.

However, keep in mind that grouping by all columns may not be the best option performance-wise.

Dragan Bozanovic
  • 23,102
  • 5
  • 43
  • 110
  • Do you think better to have customerIds and then load it separately (new select) in case of millions records? Will it be wise? – kadkaz Jan 29 '16 at 15:31
  • Hopefully, you don't mean you load millions of records. In that case no solution will work. :) But if you group by all columns among millions of records, then yes, I would say avoiding that by using other approaches should yield better performance. – Dragan Bozanovic Jan 29 '16 at 15:35