Classes annotated with @XmlTransient are still mapped to XML · Issue #794 · javaee/jaxb-v2 (original) (raw)
The JAXB javadoc states:
"When placed on a class, it indicates that the class shouldn't be mapped to XML
by itself. Properties on such class will be mapped to XML along with its derived
classes, as if the class is inlined."
Therefore, I expected that, given the code snippet below as an example, the
class Book would not be included in schema.xsd after running schemagen. But
schemagen is including it in the generated XML schema.
@XmlTransient
public class Book {
public String title;
public String author;
public String isbn;
}
@XmlRootElement
public class Library
{ @XmlElementWrapper(name="books") @xmlelement(name="book") @XmlJavaTypeAdapter(BookISBNAdapter.class) public Set book; }
public class BookISBNAdapter extends XmlAdapter<String, Book> {
public String marshal(Book book)
{ return book.isbn; }
public Book unmarshal(String isbn)
{ return BookLookupService.getByISBN(isbn);}
}
Environment
Operating System: All
Platform: All
Affected Versions
[2.2]