Note that there are some explanatory texts on larger screens.

plurals
  1. POJAXB - XJC settings not to generate Map to List of Key-Value pair conversion bit direct binding
    primarykey
    data
    text
    <p>Is there a possibility to force XJC not to generate Map to List of Key-Value pairs conversion?</p> <p>When I take Jaxb annotated class </p> <pre><code>@XmlRootElement public class Customer { private Map&lt;String, Address&gt; addressMap = new HashMap&lt;String, Address&gt;(); public Map&lt;String, Address&gt; getAddressMap() { return addressMap; } public void setAddressMap(Map&lt;String, Address&gt; addressMap) { this.addressMap = addressMap; } } </code></pre> <p>And generate schema via schemagen I will get following xsd schema:</p> <pre><code> &lt;xs:element name="customer" type="customer"/&gt; &lt;xs:complexType name="address"&gt; &lt;xs:sequence&gt; &lt;xs:element name="street" type="xs:string" minOccurs="0"/&gt; &lt;/xs:sequence&gt; &lt;/xs:complexType&gt; &lt;xs:complexType name="customer"&gt; &lt;xs:sequence&gt; &lt;xs:element name="addressMap"&gt; &lt;xs:complexType&gt; &lt;xs:sequence&gt; &lt;xs:element name="entry" minOccurs="0" maxOccurs="unbounded"&gt; &lt;xs:complexType&gt; &lt;xs:sequence&gt; &lt;xs:element name="key" minOccurs="0" type="xs:string"/&gt; &lt;xs:element name="value" minOccurs="0" type="address"/&gt; &lt;/xs:sequence&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; &lt;/xs:sequence&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; &lt;/xs:sequence&gt; </code></pre> <p></p> <p>When I generate jaxb annotated classes back via xjc with specified bindings:</p> <pre><code> &lt;jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.1"&gt; &lt;jaxb:bindings schemaLocation="schema1.xsd"&gt; &lt;jaxb:bindings node="//xs:complexType[@name='customer']//xs:element[@name='addressMap']"&gt; &lt;jaxb:property&gt; &lt;jaxb:baseType name="java.util.HashMap&amp;lt;String,Address&amp;gt;" /&gt; &lt;/jaxb:property&gt; &lt;/jaxb:bindings&gt; &lt;/jaxb:bindings&gt; &lt;/jaxb:bindings&gt; </code></pre> <p>I will get back:</p> <pre><code> @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "customer", propOrder = { "addressMap" }) public class Customer { @XmlElement(required = true) @XmlJavaTypeAdapter(MapAdapter.class) protected HashMap&lt;String, Address&gt; addressMap; public HashMap&lt;String, Address&gt; getAddressMap() { return addressMap; } public void setAddressMap(HashMap&lt;String, Address&gt; value) { this.addressMap = value; } @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { "entry" }) public static class AddressMap { protected List&lt;Customer.AddressMap.Entry&gt; entry; public List&lt;Customer.AddressMap.Entry&gt; getEntry() { if (entry == null) { entry = new ArrayList&lt;Customer.AddressMap.Entry&gt;(); } return this.entry; } @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { "key", "value" }) public static class Entry { protected java.lang.String key; protected blog.map.generated.Address value; public java.lang.String getKey() { return key; } public void setKey(java.lang.String value) { this.key = value; } public blog.map.generated.Address getValue() { return value; } public void setValue(blog.map.generated.Address value) { this.value = value; } } } } </code></pre> <p>That's not what I exactly wanted. Is there a way to get my "original" input?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload