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

后端 未结 21 1980
孤街浪徒
孤街浪徒 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条回答
  •  猫巷女王i
    2020-11-22 09:37

    Simple way to converting SQL query to POJO class collection ,

    Query query = getCurrentSession().createSQLQuery(sqlQuery).addEntity(Actors.class);
    List list = (List) query.list();
    return list;
    

提交回复
热议问题