I have a class Product
with the following properties: name
, dateCreated
, createdByUser
, dateModified
and modifiedByUser
, and I'm using JAXB marshalling. I'd like to have output like this:
<product>
<name>...</name>
<auditInfo>
<dateCreated>...</dateCreated>
<createdByUser>...</createdByUser>
<dateModified>...</dateModified>
<modifiedByUser>...</modifiedByUser>
</auditInfo>
</product>
but ideally I'd like to avoid having to create a separate AuditInfo
wrapper class around these properties.
Is there a way to do this with JAXB annotations? I looked at @XmlElementWrapper
but that's for collections only.