| Summary: | Possible Bug - Behaviour difference when @XmlJavaTypeAdapter/@XmlSchemaType are used at the package and property levels | ||||||
|---|---|---|---|---|---|---|---|
| Product: | z_Archived | Reporter: | Blaise Doughan <blaise.doughan> | ||||
| Component: | Eclipselink | Assignee: | Blaise Doughan <blaise.doughan> | ||||
| Status: | RESOLVED INVALID | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | david.twelves | ||||
| Version: | unspecified | ||||||
| Target Milestone: | --- | ||||||
| Hardware: | PC | ||||||
| OS: | Windows XP | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
Created attachment 200615 [details]
Code demonstrating the bug
This is not a bug and is working correctly. The package level XmlAdapter is applied to PackageLevel.date and changes the "value" type from Date to String, since the value type is now String and not Date the @XmlSchemaType specified at the package level does not apply. The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink |
There is a difference in behaviour when @XmlJavaTypeAdapter and @XmlSchemaType are used together at the package and property levels. PROPERTY LEVEL package foo; import java.util.Date; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlSchemaType; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; public class PropertyLevel { @XmlJavaTypeAdapter(DateAdapter.class) @XmlSchemaType(name="date") @XmlElement private Date date; } PACKAGE LEVEL package foo; import java.util.Date; import javax.xml.bind.annotation.XmlElement; public class PackageLevel { @XmlElement private Date date; } @XmlJavaTypeAdapters( @XmlJavaTypeAdapter(value=DateAdapter.class, type=Date.class) ) @XmlSchemaTypes({ @XmlSchemaType(name="date", type=Date.class) }) package foo; import javax.xml.bind.annotation.adapters.*; import javax.xml.bind.annotation.*; import java.util.Date; --- GENERATED SCHEMA Note how the type of the date elements is different. <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <xs:schema version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:complexType name="packageLevel"> <xs:sequence> <xs:element name="date" type="xs:string" minOccurs="0"/> </xs:sequence> </xs:complexType> <xs:complexType name="propertyLevel"> <xs:sequence> <xs:element name="date" type="xs:date" minOccurs="0"/> </xs:sequence> </xs:complexType> </xs:schema>