I would like to express the following query
select * from(
select pI, max(pAs) as pAs from mytable
and pAs>=?1 and pAs<=?2
and pI like 'DE%%'
and pE like ?6
group by pI
) as x
inner join mytable as a
on a.pI=x.pI
and a.pAs=x.pAs
using the criteriabuilder from hibernate. I did not succeed and thus far use a nativeQuery instead.
However, the crux of the matter (which i could not resolve) appears to be that I need two properties returned in the subselect. All the examples i found only return one property.
Is this really a limitation of jpa/hibernate or is there a way to do what i want? Any help/pointers are appreciated.