I have problem on returning query result set using entityManager object . I want to return my join query which should convert into pojo object.
so after many tries I found the below working code
public List<Test> getData() {
Query a = entityManager.createNativeQuery("select t1.data1,t2.data2 from test1 t1 join test2 t2 on t1.id = t2.id");
a.unwrap(SQLQuery.class)
.addScalar("data1", LongType.INSTANCE)
.addScalar("data2", DoubleType.INSTANCE)
.setResultTransformer(Transformers.aliasToBean(Test.class));
return a.getResultList();
}
But I had warnings that setResultTransformer() and addScalar() methods are deprecated.
Can any one please put the alternative code of it or please provide the solution.
Thanks.