Regarding the following example, is it possible to retrieve list of AnsweredQuestion instances as objects of Question?
@MappedSuperclass
public abstract class Question{
@Column(name="TITLE")
private String title;
...
}
@Entity
@Table(name="ANSWEREDQUESTION")
public class AnsweredQuestion extends Question
{
@Column(name="ANSWER")
private String answer;
...
}
It is very important for me to retrieve only a few columns since the descendant class has many. I tried something as follows, but it still returns list of AnsweredQuestion:
queryStr = " select q from AnsweredQuestion q where ..."
TypedQuery<Question> query = entityManager.createQuery(queryStr, Question.class);
return query.setParameter( ... ).getResultList();