xml - java - JAXB Null value -
maybe simple request, haven't found way it.
i have build xml output these one:
<person name="mike"> <orders id="1"> <order ido="1"></order> </orders> </person>
i have values query in db, in case querys returns no "orders" xml have this:
<person name="mike"> </orders> <person>
is these possible?, know kind of strange requirement of client.
i know have case in our code often. define xml first xsd, , generate jaxb. so, orders 0..1, , list inside orders 1..n.
if annotating classes, think need this:
@xmlelement(name = "orders") protected list<order> orders; public list<order> getorders() { if (orders == null) { orders = new arraylist<order>(); } return this.orders; }
this return list. if list empty, should <orders /> returned.
Comments
Post a Comment