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 4034690
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:00:15+00:00 2026-05-20T12:00:15+00:00

I am working in an application where we need to save objects in XML

  • 0

I am working in an application where we need to save objects in XML format, and load them later once required. For this I have used JAXB to marshall and unmarshall XMLs back to Java classes.

My problem is that the I have to change Java models sometime (by adding, renaming or deleting attributes), as a result, I will have incompatible saved XMLs which can’t be bound back to the new class form.

To solve this, every time I have to do a change I take a copy of all the classes under a new package (named after its version) and apply the requested changes. And when saving an XML I save its version so that I can decide which package should be scanned by JAXB to unmarshall this XML.

My question is, Is there any other way to implement backward and forward compatibility using JAXB? If not is there any other technology that can support this?

  • 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-05-20T12:00:15+00:00Added an answer on May 20, 2026 at 12:00 pm

    Note: I am a member of the JAXB 2 (JSR-222) expert group and lead EclipseLink JAXB (MOXy).

    For this use case I prefer to use a single model when possible. This will require that you have multiple mappings for your object model. The JAXB spec does not provide a means to do this, but it can be done using MOXy’s externalized metadata extension:

    • http://bdoughan.blogspot.com/2010/12/extending-jaxb-representing-annotations.html

    The metadata can be used to supplement the annotations, or used to replace them. So I would recommend mapping your base schema with annotations and using the XML format to modify the metadata per version of the schema.

    My problem is that the I have to
    change Java models sometime (by
    adding, renaming or deleting
    attributes) , as a result, I will have
    incompatable saved XMLs which can’t be
    bound back to the new class form.

    Deleting a Java attribute (field/property) makes things difficult since there will be nothing for the old XML to map to. Instead you can leave them in your model, and mark them “@XmlTransient” in the XML metadata files.

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

Sidebar

Related Questions

I'm working in a .net application where we need to generate XML files on
I need to have a working web browser in a fullscreen Direct3D application. For
I am working on an application where i need to transfer mails from a
I'm working on a web-application and need to figure out the best way to
I am working on an ASP.NET MVC application where I need to export data
I'm working on an asp.net application which uses Lucene.net I need to highlight the
I need to add DVD writing functionality to an application I'm working on. However
I'm working on a P2P application, and I need to get it to communicate
I'm working on a new project, a web application, where I need to focus
I have an application which displays properties dialogs for various GUI-accessible objects. Because there

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.