In standard SQL, the group by clause must contain every selected value except the ones which are aggregate functions.
select a, b, c, d, sum(e) from table group by a -- INVALID
select a, b, c, d, sum(e) from table group by a, b -- INVALID
select a, b, c, d, sum(e) from table group by a, b, c -- INVALID
select a, b, c, d, sum(e) from table group by a, b, c, d -- VALID
The query generated by Hibernate is thus invalid, and AFAIK, the only possible way to make a group by HQL query work is to list every scalar column you want to select explicitely (see https://hibernate.onjira.com/browse/HHH-1615):
select m.foo, m.bar, m.creationTime, m.batchUser
from ManualUrlBatchModel m
where m.status IN(:status)
group by m.foo, m.bar, m.creationTime, m.batchUser
order by m.creationTime
If your original query works with MySQL, it's because MySQL doesn't respect the SQL standard, and allows queries with group by
not listing every selected column. I would suggest not relying on this "feature", using the same database in tests and in production, and using PostgreSQL instead of MySQL.