I have a method:
public List<Timetable> getTimetableTableForRegion(String id) {
List<Timetable> timetables;
TypedQuery<Timetable> query = em_read.createQuery("SELECT ..stuff.. where R.id = :id", Timetable.class).setParameter("id", Long.parseLong(id));
timetables = query.getResultList();
return timetables;
}
which returns this:
so, what am I missing in order to return a list of Timetable
's?
ok, so, ..stuff..
part of my JPQL contained an inner join to other table. Even through in SELECT there were selected fields just from one table, which was used as type - Timetable
, Eclipslink was unable to determine if this fields are part of that entity and instead of returning list of defined entity returned list of Object[]
.
So in conclusion: Use @OneToMany/@ManyToOne mappings (or flat table design) and query just for ONE table in your JPQL to be able to typize returned entities.