JAX-B annotations for elements that inherit from a parent
- by AlexM
When adding JAX-B Java annotations for Java classes - if I have a parent Class Entry, with two children, Book and JournalArticle,
Would I add these annotations for all three classes:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement
ie:
@XmlSeeAlso({au.com.library.Book.class, au.com.library.JournalArticle.class})
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement
public abstract class Entry implements Serializable{
private static final long serialVersionUID = -1895155325179947581L;
@XmlElement(name="title")
protected String title;
@XmlElement(name="author")
protected String author;
@XmlElement(name="year")
protected int year;
and
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement
public class Book extends Entry {
@XmlElement(name="edition")
private String edition;
@XmlElement(name="publisher")
private String publisher;
@XmlElement(name="placeOfPublication")
private String placeOfPub;
and
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement
public class JournalArticle extends Entry {
@XmlElement(name="journalTitle")
private String journalTitle;
@XmlElement(name="volume")
private String volume;
@XmlElement(name="issue")
private String issue;
@XmlElement(name="pageNumbers")
private String pgNumbers;