Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8559321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:00:55+00:00 2026-06-11T16:00:55+00:00

Lets say i have class @XmlType(propOrder = { one, two }) @XmlRootElement(name = search)

  • 0

Lets say i have class

@XmlType(propOrder = {
        "one",
        "two"
    })

@XmlRootElement(name = "search")
public class Search {

    protected One one;  
    protected Two two;

    //getters & setters
}

and i wanted a class that extends this class

e.g.

@XmlType(propOrder = {
        "three"
    })

@XmlRootElement(name = "searchExtended")
public class SearchExtended extends Search {

    protected Three three;  
    //getters & setters
}

how do you declare the propOrder correctly, i have tried this before and it did not use the order i thought it would. How is this handled by annotations? / how should you be declaring this across extended classes?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T16:00:56+00:00Added an answer on June 11, 2026 at 4:00 pm

    The parents properties will be marshalled based on their specified ordering before the child properties. You can include the properties from the parent class in the propOrder of the child class if you annotate the parent class with @XmlTransient.

    • http://blog.bdoughan.com/2012/08/jaxbs-xmltransient-and-property-order.html

    UPDATE

    Is there a way i can make it transistant but still use it normally?

    No, setting @XmlTransient on a class removes it from the classes that JAXB considers mapped. The reason that JAXB marhals the properties of the super class before the properties of the subclass is to match the rules of XML schema. When your Search class is not marked with @XmlTransient the corresponding XML schema is the following. According to the XML schema rules in order for a element of type searchExtended to be valid the elements from the super type must occur before any elements defined in the subtype.

      <xs:complexType name="searchExtended">
        <xs:complexContent>
          <xs:extension base="search">
            <xs:sequence>
              <xs:element name="three" type="three" minOccurs="0"/>
            </xs:sequence>
          </xs:extension>
        </xs:complexContent>
      </xs:complexType>
    
      <xs:complexType name="search">
        <xs:sequence>
          <xs:element name="one" type="one" minOccurs="0"/>
          <xs:element name="two" type="two" minOccurs="0"/>
        </xs:sequence>
      </xs:complexType>
    

    You can see the XML schema that corresponds to your JAXB model by running the following code:

    import java.io.IOException;
    import javax.xml.bind.*;
    import javax.xml.transform.Result;
    import javax.xml.transform.stream.StreamResult;
    
    public class Demo {
    
        public static void main(String[] args) throws Exception {
            JAXBContext jc = JAXBContext.newInstance(SearchExtended.class);
            jc.generateSchema(new SchemaOutputResolver() {
    
                @Override
                public Result createOutput(String namespaceUri,
                        String suggestedFileName) throws IOException {
                    StreamResult result = new StreamResult(System.out);
                    result.setSystemId(suggestedFileName);
                    return result;
                }
    
            });
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say i have following class public class abc { int id; string name;
Lets say I have class Person { public Person(int age, string name) { Age
Lets simplify. Lets say I have this class: class Foo { public string Name
Lets say I have the following class: public class Provider { ... public sealed
Lets say have this immutable record type: public class Record { public Record(int x,
Lets say I have an abstract class: abstract class MyAbstract { protected abstract object
Lets say I have the code: class NoneDict(dict): def __getitem__(self, name): try: return super(NoneDict,
Lets say I have a class User. A user got a name, gender, ...,
Lets say I have a class like this in class1.vb: Public Class my_class Public
Lets say I have a class like this in Java: public class Function {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.