JPA : How to convert a native query result set to POJO class collection

后端 未结 21 1498
孤街浪徒
孤街浪徒 2020-11-22 09:23

I am using JPA in my project.

I came to a query in which I need to make join operation on five tables. So I created a native query which returns five fields.

21条回答
  •  孤街浪徒
    2020-11-22 09:43

    We have resolved the issue using following way :

       //Add actual table name here in Query
        final String sqlQuery = "Select a.* from ACTORS a"
        // add your entity manager here 
        Query query = entityManager.createNativeQuery(sqlQuery,Actors.class);
        //List contains the mapped entity data.
        List list = (List) query.getResultList();
    

提交回复
热议问题