Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 353446 - Possible Bug - Behaviour difference when @XmlJavaTypeAdapter/@XmlSchemaType are used at the package and property levels
Summary: Possible Bug - Behaviour difference when @XmlJavaTypeAdapter/@XmlSchemaType a...
Status: RESOLVED INVALID
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: Blaise Doughan CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-29 16:46 EDT by Blaise Doughan CLA
Modified: 2022-06-09 10:14 EDT (History)
1 user (show)

See Also:


Attachments
Code demonstrating the bug (1.96 KB, application/x-zip-compressed)
2011-07-29 17:01 EDT, Blaise Doughan CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Blaise Doughan CLA 2011-07-29 16:46:47 EDT
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>
Comment 1 Blaise Doughan CLA 2011-07-29 17:01:30 EDT
Created attachment 200615 [details]
Code demonstrating the bug
Comment 2 Blaise Doughan CLA 2012-04-30 14:30:41 EDT
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.
Comment 3 Eclipse Webmaster CLA 2022-06-09 10:08:13 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink
Comment 4 Eclipse Webmaster CLA 2022-06-09 10:14:28 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink