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

Bug 345036

Summary: Two mappings shown up in the JAXB content for a field/property
Product: [WebTools] Dali JPA Tools Reporter: Nan Li <nan.n.li>
Component: JAXBAssignee: dali.general-inbox <dali.general-inbox>
Status: CLOSED INVALID QA Contact:
Severity: normal    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Nan Li CLA 2011-05-06 17:08:52 EDT
Build Identifier: I20110428-0848

Given a class like the one below:

@XmlAccessorType(XmlAccessType.PROPERTY) <--
@XmlType(name="test")
public class Test {

	@XmlAttribute    <--
	private int id;

	public int getId() {
	  return id;
	}

	public void setId(int id) {
	  this.id = id;
	}
}

If annotating a field (id in this example) with @XmlAttribtue or @XmlElement, you would get two mappings for that field in the JAXB content if not specifying @XmlAccessorType annotation or specifying the access type as PROPERTY with @XmlAccessorType(XmlAccessType.PROPERTY).

Reproducible: Always
Comment 1 Nan Li CLA 2011-05-06 17:23:59 EDT
OK. This is a valid case based on the spec. (8.12.5 Property / Field).