Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Problem with ObjectGraph and xml attributes
Problem with ObjectGraph and xml attributes [message #1066187] Mon, 01 July 2013 13:07
Joni Ollila is currently offline Joni OllilaFriend
Messages: 1
Registered: July 2013
Junior Member

If I have following class hierarchy:

class A {
private String fieldA1 = "fieldA1";
private String fieldA2 = "fieldA2";

private B fieldB = new B();

class B {
private String fieldB1 = "fieldB1";

private String fieldB2 = "fieldB2";

I get following XML output:

<B fieldB2="fieldB2">fieldB1</B>

Now if I use new ObjectGraph feature:

ObjectGraph graph = JAXBHelper.getJAXBContext(context).createObjectGraph(A.class);
graph.addAttributeNodes("fieldA1", "fieldA2", "fieldB");
marshaller.setProperty(MarshallerProperties.OBJECT_GRAPH, graph);

I get following XML:


As you can see 'fieldB2' annotated with XmlAttribute is missing, but 'fieldB1' annotated with XmlValue is present. Is this really working as it should be? I would like to see in this case also 'fieldB2' there.

This example was simple, but we have quite complicated object structure and it is really pain in the ass if I have to include all attribute fields to 'addAttributeNodes' method.If this is really intended behavior, is there some way to get all the subclass fields (also attributes), when using object graph?

Previous Topic:Multiple JPA Persistences loading issue in JBOSS 5
Next Topic:Birt with JBOSS 5 Issue
Goto Forum:

Current Time: Wed Dec 02 07:06:26 GMT 2015

Powered by FUDForum. Page generated in 0.02420 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software