Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JAXB multiple inheritance propOrder

I have a structure like

public class Grandpa...

public class Father extends Grandpa...

public class Son extends Father...

I want to marshall it to file with propOrder annotation.

So i can use @XmlTransient on Grandpa and set propOrder on Father class, but How can i apply propOrder to all 3 classes?

As i understand '@XmlTransient'-approach is only for one super class, and one child class?

like image 710
Eugene Kisly Avatar asked Oct 21 '22 18:10

Eugene Kisly


1 Answers

When you specify @XmlTransient on a class as far as JAXB is concerned you remove it from the inheritance hierarchy and its properties are considered part of its children. This means if you mark Father as transient you can include its properties in the propOrder for Son. If you mark Grandpa and Father as transient then you could include the properties from both classes in the propOrder for Son.

Without @XmlTransient you can still use propOrder, but in that propOrder you can only specify the properties that correspond to that class. This corresponds to the ordering of elements that occurs with extended complex types, inherited properties appear first.

For More Information

  • http://blog.bdoughan.com/2012/08/jaxbs-xmltransient-and-property-order.html
like image 69
bdoughan Avatar answered Oct 23 '22 10:10

bdoughan