Multiple mappings for a single xml element [message #1297801] |
Tue, 15 April 2014 22:58 |
Mar Sah Messages: 2 Registered: April 2014 |
Junior Member |
|
|
The Eclipse Link moxy documentation describes how to have multiple mappings for a single property. Instead I need to have a single xml element map to multiple java attributes. Is this possible? Unfortunately I have no control over the class hierarchy or the xml schema.
Here is an example of the xml:
<Order>
<Id>OrderId1</Id>
<CustomerId>Customer001</CustomerId>
<GroupId>Group1</GroupId>
<Quantity>5</Quantity>
</Order>
The Java classes would look like this.
public class Order {
PayIdentity payer;
String orderId;
String customerId;
String groupId;
long quantity;
}
public class Payer {
String customerId;
String groupId;
}
Excerpt from mappings file:
<java-type name="Order" xml-accessor-type="NONE" >
<java-attributes>
<xml-element java-attribute="payer" xml-path="."
type="PayIdentity" />
<xml-element java-attribute="orderId" name="Id" />
<xml-element java-attribute="customerId" name="CustomerId" />
<xml-element java-attribute="groupId" name="GroupId" />
<xml-element java-attribute="quantity" name="Quantity" />
</java-attributes
</java-type>
<java-type name="PayIdentity" xml-accessor-type="NONE" >
<java-attributes>
<xml-element java-attribute="customerId" name="CustomerId" />
<xml-element java-attribute="groupId" name="GroupId" />
</java-attributes
</java-type>
The problem is that the inclusion of the payer mapping causes the customerId and groupId attributes in the Order class to be null.
|
|
|
Powered by
FUDForum. Page generated in 0.05586 seconds