Thanks Joel-- it sounds like you’re saying this is a behavior (bug?) in Hibernate. Is it true that someone using the Hibernate libraries directly in Java would encounter the same issue? If it’s a Hibernate thing, I would assume someone has run into this before. I wonder if there’s any known workarounds or Hibernate bug tickets to address it. Or perhaps, it’s considered to be proper behavior…
I’m not even sure it’s a bug anywhere. Criteria Builder (on both sides) is doing what it’s asked, and preparing SQL according to the criteria provided.
RE: doing it in Java, yes, the result would be the same. Here are some people complaining of the same issues:
It seems like the workaround is more or less to do what Don and I have done–run the count() before list(), or do two separate criteria queries with the same criteria (sans orderings on the count()).