I have this query
String query = "select ig.p1,
ig.p2,
ig.p3,
tg.p4
from mytable ig, mytable2 tg
where ..... and ....";
And I have DTO
public class MyDto{
//constructor
private String p1;
private String p2;
private String p3;
private String p4;
...
//getters/setters
}
I need get this select and mapping to DTO.
I create this in my DTO
@SqlResultSetMapping(
name="findReport",
classes={
@ConstructorResult(
targetClass=MyDto.class,
columns={
@ColumnResult(name="p1",type = String.class),
@ColumnResult(name="p2", type = String.class),
@ColumnResult(name="p3", type = String.class),
@ColumnResult(name="p4", type = String.class),
}
)
}
)
And create DAO/Repository
@Component
public class ReportRepositoryImpl implements ReportRepository {
@PersistenceContext
private EntityManager em;
@Override
public Report findReportSelect() {
Query query = em.createNativeQuery(
"query","findReport");
@SuppressWarnings("unchecked")
Collection<MyDto> dto = query.getResultList();
Iterable<MyDto> itr = dto;
return (MyDto)itr;
}
}
But I have error unchecked
My quations 1. How can I fix this error and what this error means? 2. Is there more easy way get this result?