Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 334554

Summary: @XmlPath and @XmlEnum
Product: z_Archived Reporter: Blaise Doughan <blaise.doughan>
Component: EclipselinkAssignee: Nobody - feel free to take it <nobody>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: eclipselink.oxm-inbox
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Bug Depends on:    
Bug Blocks: 332770    
Attachments:
Description Flags
MOXy - Fix
none
MOXy - Test Cases none

Description Blaise Doughan CLA 2011-01-17 12:48:50 EST
There appears to be an error when using @XmlPath with @XmlEnum.  For the following example:

@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class Customer {

  @XmlPath("nested/type/text()")
  private CustomerType type = CustomerType.NEW_CUSTOMER;

  @XmlEnum(String.class)
  private enum CustomerType { PROMO_CUSTOMER, NEW_CUSTOMER, VIP, NORMAL }

}

When the following XML document is unmarshalled the type property is not set:

<customer>
  <nested>
    <type>NEW_CUSTOMER</type>
  </nested>
</customer>

Everything works properly when @XmlElement is used instead of @XmlPath
Comment 1 Blaise Doughan CLA 2011-01-18 16:40:59 EST
Created attachment 187052 [details]
MOXy - Fix

When an Enum property was marked with an @XmlPath annotation, the specified XPath was being ignored and an XPath was derived from the field/property name.

Fix:
Modified the MappingsGenerator.getXPathForField to always account for an XPath being specified on the property.
Comment 2 Blaise Doughan CLA 2011-01-19 11:31:20 EST
Created attachment 187128 [details]
MOXy - Test Cases
Comment 3 Blaise Doughan CLA 2011-01-20 15:00:39 EST
Fix checked into trunk at rev:  8850

Code reviewed by:  Matt MacIvor
Comment 4 Eclipse Webmaster CLA 2022-06-09 10:26:14 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink