the following query generates illegal SQL if the entity uses an embeddable as primary key:
This is just the simplest example for such a query. In reality the query is much more complicated and involves left joins (the reason for the distinct). It does not matter whether this is done in JPQL or as a criteria query.
The generated SQL is not legal in Oracle:
Trying to reformulate as e.g. distinct concat(field1,field2) fails in HQL. For Oracle in particular the correct SQL should probably look more like:
Hibernate 4.3.7 and 4.3.10 / Oracle 11g