Is there a way in JPA to convert random select clause values using createNativeQuery to a domain object. The domain object is not managed
I have the following sql query
select name, count(*) as cnt, sum(average_events)/count(*) as avg_events from (complex subquery)
I want to convert the values a,b,c into a domain object with three instance variables a, b and c. This domain object is not managed by JPA and hence does not have @Entity and no corresponding table.
Currently I am doing the following, which returns a list of objects.
Query query = objectManager.getEntityManager().createNativeQuery(sqlStr);
List resultList = query.getResultList();
Use this syntax:
Where
MyCustomObjectis any class with matching consdtructor:Scala bonus: equivalent class: