java - JAXB Marshaller does not print attributes of subclass -


i have got class "contract" contains list of instances of concrete subclasses of abstract class "condition".

@onetomany(mappedby = "givenoncontract", cascade =  cascadetype.all, fetch = fetchtype.lazy, targetentity = condition.class) @privateowned @xmlelement(name = "condition", type =  modell.contract.condition.condition.class) @xmlelementwrapper(name = "conditions") private list<condition> conditions = new arraylist<condition>(); 

the class "condition" has got attribute "sortingnumber". add list in contract instance of class "manualcondition" (a concrete subclass of "condition"). class has got attribute named "value"

when marshall object tree (contract->conditions) attribute of "condition" printed, not 1 of subclass manualcondition.

public static string printxml(abstractmodelobject objekt) throws  jaxbexception {     final jaxbcontext context = jaxbcontext.newinstance(objekt.getclass());     final bytearrayoutputstream output = new bytearrayoutputstream();      final marshaller marshaller = context.createmarshaller();     marshaller.setproperty(marshaller.jaxb_fragment, boolean.false);     marshaller.setproperty(marshaller.jaxb_formatted_output, boolean.true);     marshaller.setadapter(new productconfigurationxmladapter(null));     marshaller.marshal(objekt, output);     final string jaxbencoding = (string)  marshaller.getproperty(marshaller.jaxb_encoding);      try {         return new string(output.tobytearray(), jaxbencoding);     } catch (unsupportedencodingexception uee) {         throw new runtimeexception(uee);     } } 

when add annotation @xmlseealso(manuellekondition.class) before class definition of "condition", attributes of subclass manualcondition printed. solution not satisfactory us, because have add annotation several places in our code (there far more classes 2 mentioned)

does know easier solution print attributes including ones on subclasses? somehow possible via configuration/setting of properties on marshaller?


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -