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

  • Home
  • SEARCH
  • 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 8613137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:47:54+00:00 2026-06-12T04:47:54+00:00

We have a class with a JAXB annotation on one property. We then have

  • 0

We have a class with a JAXB annotation on one property. We then have several subclasses which annotate the rest of the important data. We have one subclass, however, where we want to ignore the parent class annotation so that it does not get marshalled. Here’s some example code.

Parent class:

@XmlType(name="Request")
@XmlAccessorType(XmlAccessorType.NONE)
public abstract class Request {
    @XmlElement(required=true)
    private UUID uuid;

    ... setter/getter
}

Now for the subclass:

@Xsd(name="concreteRequest")
@XmlRootElement("ConcreteRequest")
@XmlType(name="ConcreteRequest")
@XmlAccessorType(XmlAccessorType.FIELD)
public class ConcreteClass {
    @XmlElement(required=true)
    private String data1;
    @XmlElement(required=true)
    private String data1;

    ... setters/getters ...
}

When I masrhall an instance of ConcreteClass I get the following XML:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ConcreteRequest>
    <uuid>uuid</uuid>
    <data1>data</data1>
    <data2>data</data3>
</ConcreteRequest>

Where I want XML like this:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ConcreteRequest>
    <data1>data</data1>
    <data2>data</data3>
</ConcreteRequest>

We have other implementations of Request, however that do require the UUID, this is just a special case. Is there a way to ignore the UUID field in my ConcreteRequest?

  • 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-12T04:47:55+00:00Added an answer on June 12, 2026 at 4:47 am

    I hope, I understood your problem. Here is the solution.

    JAXB provides @XmlTransient(javax.xml.bind.annotation.XmlTransient)(javadoc) to ignore any field during marshalling.

    Override the field “uuid” as @XmlTransient in your derived class (ConcreteRequest.class) along with its correspoding Getter/Setter method. It is necessary to override the Getter/Setter methods also, these will be invoked during marshalling.

    @Xsd(name="concreteRequest")
    @XmlRootElement("ConcreteRequest")
    @XmlType(name="ConcreteRequest")
    @XmlAccessorType(XmlAccessorType.FIELD)
    public class ConcreteClass {
        @XmlElement(required=true)
        private String data1;
        @XmlElement(required=true)
        private String data2;
        @XmlTransient
        private UUID uuid;
    
        ... setters/getters ...
    }
    

    This will override your Base Class attribute.

    Get back to me for more information.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have Class and Student objects. Both have collection of another as property. Which
I have the following java class with the JAXB @XMLRootElement annotation @XmlRootElement(name=ClientData) public class
Is there a JAXB annotation to ignore a parent class, when you have an
I have class LegacyClass which inherits OldBaseClass. I'm considering a change to introduce a
We have class lua. In lua class there is a method registerFunc() which is
I have class like this below shown. which contains the shopping items where the
I have a JAX-RS REST service implemented using Jersey. One of the cool features
I have a JAXB class like this: public class Game { private Date startTime;
I'm using JAXB for quick-and-dirty XML generation. I have a class that represents a
I have created a spring-batch job. My reader class reads the data from the

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.