JAXB (JSR-222)プロバイダーとして Eclipselink 2.3.2 を使用しています。アイテムのリストとページネーション リンクのセットで構成される一般的なリストを作成しました。
import java.util.List;
import javax.xml.bind.annotation.*;
@XmlRootElement(name = "listdata")
public class ListEntity<T> {
@XmlElementRef
public List<T> data;
@XmlElementRef
public PaginationLinks links;
public ListEntity(List<T> data) {
this.data = data;
}
public ListEntity() {
}
}
私の実際のエンティティ
@XmlRootElement(name="authorization")
public class AuthorizationDTO {
@XmlElement
public String referenceNumber;
}
そのため、リストの作成後にマーシャリングしようとすると、次のエラーが発生します。リストデータの @XmlElement で問題なく動作しますが、オブジェクト表現を作成するため、明らかに使用できません
Caused by: Exception [EclipseLink-50006] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.JAXBException
Exception Description: Invalid XmlElementRef on property data on class com.ofss.fc.botg.infra.model.ListEntity. Referenced Element not declared.