Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Multiple mappings for a single xml element
Multiple mappings for a single xml element [message #1297801] Tue, 15 April 2014 22:58
Mar Sah is currently offline Mar SahFriend
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.
Previous Topic:Invoke JPA entity creation process from a script
Next Topic:Custom PoolDataSource - How to change in EclipseLink
Goto Forum:
  


Current Time: Tue Dec 23 02:18:53 GMT 2014

Powered by FUDForum. Page generated in 0.02199 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software