Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 333162 - schema generation with annotated static field is incorrect
Summary: schema generation with annotated static field is incorrect
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: Matt MacIvor CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-23 11:12 EST by Karen Butzke CLA
Modified: 2022-06-09 10:08 EDT (History)
1 user (show)

See Also:


Attachments
Propsed fix. (1.14 KB, patch)
2010-12-24 10:22 EST, Matt MacIvor CLA
no flags Details | Diff
Updated fix. Statics mapped to attributes need to be writeOnly. (1.94 KB, patch)
2011-01-04 10:41 EST, Matt MacIvor CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Karen Butzke CLA 2010-12-23 11:12:05 EST
I am testing around with XmlAccessType.PUBLIC_MEMBER and hit a case where EclipseLink does not generate an attribute in the schema, but I think it should and the jdk does. foo8 a private static field annotated with @XmlAttribute does not have an attribute generated in the schema.

@XmlType
//@XmlAccessorType(XmlAccessType.PUBLIC_MEMBER) - default
public class EmployeePublicMember {
	public int foo; //persistent
	public final int foo1 = 1; //persistent
	public transient int foo2; //not persistent
	public static int foo3; //not persistent
	public static final int foo4 = 4; //not persistent
	@XmlTransient
	public int foo5; //not "persistent", but comes in to Dali context model because it's "mapped"
	@XmlAttribute
	private int foo6;//persistent
//	@XmlAttribute
//	private transient int foo7; //persistent, but invalid
	@XmlAttribute
	private static int foo8; //persistent
	@XmlAttribute
	private static final int foo9 = 9; // persistent
}

EclipseLink generates:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <xsd:complexType name="employeePublicMember">
      <xsd:sequence>
         <xsd:element name="foo" type="xsd:int"/>
         <xsd:element name="foo1" type="xsd:int"/>
      </xsd:sequence>
      <xsd:attribute name="foo6" type="xsd:int" use="required"/>
      <xsd:attribute name="foo9" type="xsd:int" use="required" fixed="9"/>
   </xsd:complexType>
</xsd:schema>

JDK generates:
<?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="employeePublicMember">
    <xs:sequence>
      <xs:element name="foo" type="xs:int"/>
      <xs:element name="foo1" type="xs:int"/>
    </xs:sequence>
    <xs:attribute name="foo6" type="xs:int" use="required"/>
    <xs:attribute name="foo8" type="xs:int" use="required"/>
    <xs:attribute name="foo9" type="xs:int" use="required"/>
  </xs:complexType>
</xs:schema>
Comment 1 Matt MacIvor CLA 2010-12-24 10:18:09 EST
Looks like this is working for private static final attributes, but not for private static.
Comment 2 Matt MacIvor CLA 2010-12-24 10:22:35 EST
Created attachment 185808 [details]
Propsed fix.
Comment 3 Matt MacIvor CLA 2011-01-04 10:41:32 EST
Created attachment 186012 [details]
Updated fix. Statics mapped to attributes need to be writeOnly.
Comment 4 Matt MacIvor CLA 2011-01-05 15:04:23 EST
Attached patch checked in to SVN
Reviewed by David McCann
Comment 5 Eclipse Webmaster CLA 2022-06-09 10:08:38 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink