I have a problem with Hibernate generating an SQL that do not work on SQLServer (works on PostgreSQL without any problems). I have tried to set the hibernate dialect for SQLServer but the same SQL is still generated and still do not work. The HQL query looks like this:
select count(t) from ValidationLog t
The generated SQL looks like this:
select count((vl.dataKey, vl.dataType)) from ValidationLog vl;
So my question is if there is anyway around it? Would really like to have the same code for both databases.
According to the JPA specification, your JPQL query is perfectly valid:
However, you might be a victim of a bug reported in issues like HHH-4044, HHH-3096, HHH-2266 (or even HHH-5419).
Possible workaround: use a state_field_path_expression.