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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:48:11+00:00 2026-05-17T19:48:11+00:00

I have a simple class CustomQuoteRequest: public class CustomQuoteRequest { private String requestId; private

  • 0

I have a simple class CustomQuoteRequest:

public class CustomQuoteRequest {

  private String requestId;

  private String currencyPairCode;

  public String getRequestId() {
    return requestId;
  }

  public void setRequestId(String requestId) {
    this.requestId = requestId;
  }

  public String getCurrencyPairCode() {
    return currencyPairCode;
  }

  public void setCurrencyPairCode(String currencyPairCode) {
    this.currencyPairCode = currencyPairCode;
  }
}

I would like to map currencyPairCode to two different attributes in the xml. This is the MOXy mapping file I am using:

<xml-bindings
    xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.eclipse.org/eclipselink/xsds/persistence/oxm http://www.eclipse.org/eclipselink/xsds/eclipselink_oxm_2_1.xsd"
    >
    <java-types>
        <java-type name="com.anz.fxeasy.domain.model.quote.CustomQuoteRequest"  xml-accessor-type="FIELD">
            <xml-root-element name="FIXML"/>
            <java-attributes>
                <xml-element java-attribute="requestId" xml-path="QuotReq/@ReqId"/>
                <xml-element java-attribute="currencyPairCode" xml-path="QuotReq/QuoteReq/Instrmt/@Sym"></xml-element>
                <xml-element java-attribute="currencyPairCode" xml-path="QuotReq/QuoteReq/Leg/Leg/@Sym"></xml-element>
            </java-attributes>
        </java-type>
    </java-types>

However the second xml-element seems to override the previous one. Any ideas?
Thanks a lot

  • 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-17T19:48:12+00:00Added an answer on May 17, 2026 at 7:48 pm

    EclipseLink MOXy 2.1.X

    In EclipseLink 2.1.X you can use an XML Customizer to accomplish this. Your external metadata would look like the following:

    <xml-bindings
        xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.eclipse.org/eclipselink/xsds/persistence/oxm http://www.eclipse.org/eclipselink/xsds/eclipselink_oxm_2_1.xsd"
        >
        <java-types>
            <java-type name="forum78.CustomQuoteRequest"  xml-accessor-type="FIELD" xml-customizer="customizer.CustomQuoteRequestCustomizer">
                <xml-root-element name="FIXML"/>
                <java-attributes>
                    <xml-element java-attribute="requestId" xml-path="QuotReq/@ReqId"/>
                    <xml-element java-attribute="currencyPairCode" xml-path="QuotReq/QuoteReq/Instrmt/@Sym"/>
                </java-attributes>
            </java-type>
        </java-types>
    </xml-bindings>
    

    In the customizer we’ll add a second mapping for the currencyCodePair property. We will need to indicate that this mapping is write only. The implementation of the XML customizer would look like the following:

    package customizer;
    
    import org.eclipse.persistence.config.DescriptorCustomizer;
    import org.eclipse.persistence.descriptors.ClassDescriptor;
    import org.eclipse.persistence.oxm.mappings.XMLDirectMapping;
    
    public class CustomQuoteRequestCustomizer implements DescriptorCustomizer {
    
        public void customize(ClassDescriptor descriptor) throws Exception {
            XMLDirectMapping  currencyPairCodeLegMapping = new XMLDirectMapping();
            currencyPairCodeLegMapping.setAttributeName("currencyPairCode");
            currencyPairCodeLegMapping.setXPath("QuotReq/QuoteReq/Leg/Leg/@Sym");
            currencyPairCodeLegMapping.setIsWriteOnly(true);
            descriptor.addMapping(currencyPairCodeLegMapping);
    
        }
    
    }
    

    EclipseLink MOXy 2.2

    In the upcoming EclipseLink 2.2 release you will be able to do this using just the externalized metadata:

    <xml-bindings
        xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.eclipse.org/eclipselink/xsds/persistence/oxm http://www.eclipse.org/eclipselink/xsds/eclipselink_oxm_2_1.xsd"
        >
        <java-types>
            <java-type name="forum78.CustomQuoteRequest"  xml-accessor-type="FIELD">
                <xml-root-element name="FIXML"/>
                <java-attributes>
                    <xml-element java-attribute="requestId" xml-path="QuotReq/@ReqId"/>
                    <xml-element java-attribute="currencyPairCode" xml-path="QuotReq/QuoteReq/Instrmt/@Sym"/>
                    <xml-element java-attribute="currencyPairCode" xml-path="QuotReq/QuoteReq/Leg/Leg/@Sym" write-only="true"/>
                </java-attributes>
            </java-type>
        </java-types>
    </xml-bindings>
    

    The following bug can be used to track this support:

    • https://bugs.eclipse.org/328135
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the simple class using auto-implemented properies: Public Class foo { public foo()
For example I have a simple class like public class Person{ public int Age
I have a very simple class with only one field member (e.g. String). Is
Say I have this simple form: class ContactForm(forms.Form): first_name = forms.CharField(required=True) last_name = forms.CharField(required=True)
I have a simple class that essentially just holds some values. I have overridden
I have a really simple class with two methods; One that will be called
I have a really simple Java class that effectively decorates a Map with input
I have a simple database table called Entries: class CreateEntries < ActiveRecord::Migration def self.up
I have a simple GUI component written in Java. The class draws an analog
Suppose I have simple class Order, that have a TotalPrice calculated property, which can

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.