What should be the semantics of size(joinAlias)? Should it add a group by for you when none exists? If so which? Since this usage is not JPA spec compliant I'd say using the join alias in size is a feature request or the bug is, that the parser doesn't throw an error at you, saying this is illegal. The real problem unfortunately is, that even when using size how it's supposed to be used(with collection valued path expressions), it doesn't work. The thing is that when a query contains a SIZE function, Hibernate must transform the query. Either a count-subuery has to replace the size, or a count on newly introduced SQL joins and group bys have to be added. A workaround for your specific example is to replace size with count. If all your code uses size on a join alias in a query that already has a group by, I'd suggest you change size to count. |