如何让Eclipse理解我期望em.createQuery(...)的类型结果?
public class ReservationDaoImpl<T extends SessionInfoEntity<T>> extends JpaDaoImpl<ReservationEntity<T>>
implements ReservationDao<T> {
public ReservationEntity<T> findById(final Long reservationId) {
em = factory.createEntityManager();
final TypedQuery<ReservationEntity<T>> resQuery =
em.createNamedQuery("ReservationEntity.findById", ReservationEntity.class)
.setParameter("reservationId", reservationId)
.setMaxResults(1);
ReservationEntity<T> resE = null;
try {
resE = resQuery.getSingleResult();
} catch( NoResultException nrEx) {
//...
}
em.close();
return resE;
}
}
Eclipse抱怨: 类型不匹配:无法转换为TypedQuery&lt; ReservationEntity&gt;调用时键入查询&lt; ReservationEntity&lt; T&gt;&gt;
final TypedQuery<ReservationEntity<T>> resQuery =
em.createNamedQuery("ReservationEntity.findById", ReservationEntity.class)
.setParameter("reservationId", reservationId)
.setMaxResults(1);