Sometimes JPQL just isnt enough… JPQL is rendered differently then expected, ie nested selects dont work… so native SQL queries need to be done…
main problem is the return value. It is possible to define SqlResultSetMappings, but these where kinda confusing. had problems with primary keys… so without these structures, a typeless list of object-array is returned:
final List result = entityManager.createNativeQuery(“SELECT a, b FROM table”).getResultList();
for each row an Object[] is put into the list.The Array contains Objects of a and b.