Bug 364182 - if a record has a primitive types field, it isn't being persisted to xml
Summary: if a record has a primitive types field, it isn't being persisted to xml
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: EDT (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P1 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-18 11:57 EST by Jing Qian CLA
Modified: 2017-02-23 14:15 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jing Qian CLA 2011-11-18 11:57:27 EST
try the program below, c and c1 isn't being written out to the xml string, where all the other fields are

package pgms;

// program
//
program myPgm
	
	
	function main()
		j Status;
		j.c = 4;
		j.c1 = 23;
		j.d = "02/23/2010";
		j.b  = 25.3;
		j.x = 4;
		j.reason = "something";
		
		s String = xmlLib.convertToXML(j, true);
		sysLib.writeStdout(s);		
end

record Status

	d date;
	c smallint;	
	c1 bigint;
	b decimal(5, 2);
	x int {@xmlattribute{}};
	reason String;
end
Comment 1 Brian Svihovec CLA 2011-11-18 16:16:59 EST
Joe,  While this issue was found in XMLLib, which is only being used by EUnit at this time, we would like to know if the problem indicates a bigger issues elsewhere in EDT.  If the problem is isolated to XMLLib, we will probably defer this until after .7.
Comment 2 Joseph Vincens CLA 2011-11-21 08:32:48 EST
XMLLib is a wrapper around JAXB conversions. This is actually a regression and was introduced when Jeff changed the function signatures of primitive parameters: ie int to Integer, long to Long, and short to Short. 
With this change the records we are no longer proper Java Beans to JAXB because the getter and setter methods types don't match (short and Short are not the same types).
	public short getC() {
		return c;
	}
	public void setC(Short ezeValue) {
		c = ezeValue;
	}

When types don't match JAXB requires an annotation to tell JAXB the field is to be serialized. In this case it requires:
	@javax.xml.bind.annotation.XmlElement()
	public short getC() {
		return c;
	}
	public void setC(Short ezeValue) {
		c = ezeValue;
	}
You can get the generator to add the annotation by changing the record field adding @XMLElement:

record Status

    d date;
    c smallint{@XMLElement};    
    c1 bigint{@XMLElement};
    b decimal(5, 2);
    x int {@xmlattribute{}};
    reason String;
end


Since we don't officially support XML for JavaGen for 070 I'm assuming this workaround will be acceptableI changed the target milestone to future and the version to 1.0. Adding the @XMLElement is a fix for XML conversion, but our records can be used as plain java beans we need to determine if the getter/setter method types need to match or is this only a JAXB problem.