Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 334554 - @XmlPath and @XmlEnum
Summary: @XmlPath and @XmlEnum
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 332770
  Show dependency tree
 
Reported: 2011-01-17 12:48 EST by Blaise Doughan CLA
Modified: 2022-06-09 10:26 EDT (History)
1 user (show)

See Also:


Attachments
MOXy - Fix (4.60 KB, patch)
2011-01-18 16:40 EST, Blaise Doughan CLA
no flags Details | Diff
MOXy - Test Cases (6.50 KB, patch)
2011-01-19 11:31 EST, Blaise Doughan CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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