我正在使用EclipseLink運行一些Native SQL。我需要將數據返回到POJO。我遵循EclipseLink Docs的指示,但我收到錯誤Missing descriptor for [Class]
將EclipseLink本機查詢結果導入POJO - [Class]的丟失描述符
查詢列已被命名爲匹配POJO的成員變量。我需要做一些額外的映射嗎?
POJO:
public class AnnouncementRecipientsFlattenedDTO {
private BigDecimal announcementId;
private String recipientAddress;
private String type;
public AnnouncementRecipientsFlattenedDTO() {
super();
}
public AnnouncementRecipientsFlattenedDTO(BigDecimal announcementId, String recipientAddress, String type) {
super();
this.announcementId = announcementId;
this.recipientAddress = recipientAddress;
this.type = type;
}
... Getters/Setters
實體Manager呼叫:
public List<AnnouncementRecipientsFlattenedDTO> getNormalizedRecipientsForAnnouncement(int announcementId) {
Query query = em.createNamedQuery(AnnouncementDeliveryLog.FIND_NORMALIZED_RECIPIENTS_FOR_ANNOUNCEMENT, AnnouncementRecipientsFlattenedDTO.class);
query.setParameter(1, announcementId);
return query.getResultList();
}
是否實體必須與表或相關的就可以了是獨立的嗎? – retrodev 2013-02-26 09:26:10
肯定這是解決問題的答案。以防萬一您想映射到DTO,那麼您可以使用@SqlResultSetMapping – 2016-11-16 09:28:30