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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:58:20+00:00 2026-06-15T04:58:20+00:00

I’m using Jersey to deliver a RESTful web service. I used javax.xml.bind.annotation to set

  • 0

I’m using Jersey to deliver a RESTful web service. I used javax.xml.bind.annotation to set up my POJO data transfer object. My DTO contains some other POJOs which provide values to the main DTO. I’m able to get JSON back from my resource in the browser, hooray, but the JSON is returning a lot more member variables of the objects and in the wrong order.

Here’s the Resource:

@Controller
@Path("/merchants/{merchantId}/profile")
public class MerchantProfileResource {

    @Autowired
    private MerchantProfileManager merchantProfileManager;

    public MerchantProfileResource() {
    }

    @GET
    @Produces("application/json")
    // TODO - wire this up
    public MerchantProfileDTO getMerchantProfile(@PathVariable String id) {
        MerchantProfileDTO merchantProfile = merchantProfileManager.getMerchantProfileDTO(id);

        return merchantProfile;
    }

    public MerchantProfileManager getMerchantProfileManager() {
        return merchantProfileManager;
    }

    public void setMerchantProfileManager(MerchantProfileManager merchantProfileManager) {
        this.merchantProfileManager = merchantProfileManager;
    }
}

Here’s the DTO class:

@XmlRootElement(name = "response")
@XmlType(propOrder={"merchantId", "email", "paymentMethods", "merchantTaxData"})
public class MerchantProfileDTO {

    @XmlElement(name = "merchantId")
    private int merchantId;

    public int getMerchantId() {
        if (merchant == null)
            return 0;
        return merchant.getMerchantid();
    }

    @XmlElement(name = "email")
    private String email;

    public String getEmail() {
        if (merchantProfile == null)
            return null;
        return merchantProfile.getEmail();
    }

    @XmlElementWrapper(name = "paymentMethods")
    @XmlElement(name = "paymentMethod")
    private List<PaymentMethod> paymentMethods;

    public List<PaymentMethod> getPaymentMethods() {
        return paymentMethods;
    }

    public void setPaymentMethods(List<PaymentMethod> paymentMethods) {
        this.paymentMethods = paymentMethods;
    }

    @XmlElement(name = "merchantTaxData")
    private MerchantTaxData merchantTaxData;

    public MerchantTaxData getMerchantTaxData() {
        return merchantTaxData;
    }

    public void setMerchantTaxData(MerchantTaxData merchantTaxData) {
        this.merchantTaxData = merchantTaxData;
    }

    private MerchantProfile merchantProfile;

    public MerchantProfile getMerchantProfile() {
        return merchantProfile;
    }

    public void setMerchantProfile(MerchantProfile merchantProfile) {
        this.merchantProfile = merchantProfile;
    }

    private Merchant merchant;

    public Merchant getMerchant() {
        return merchant;
    }

    public void setMerchant(Merchant merchant) {
        this.merchant = merchant;
    }
}

Here’s the MerchantProfile class:

@javax.persistence.Table(name = "merchant_profile", schema = "", catalog = "mexp")
@Entity
public class MerchantProfile {

    private int merchantid;

    @javax.persistence.Column(name = "merchantid", nullable = false, insertable = true, updatable = true, length = 22, precision = 0)
    @Id
    public int getMerchantid() {
        return merchantid;
    }

    public void setMerchantid(int merchantid) {
        this.merchantid = merchantid;
    }

    private String email;

    @javax.persistence.Column(name = "email", nullable = true, insertable = true, updatable = true, length = 255, precision = 0)
    @Basic
    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }
}

Here’s the Merchant class:

@javax.persistence.Table(name = "merchant", schema = "", catalog = "mexp")
@Entity
public class Merchant {

    private int merchantid;

    @javax.persistence.Column(name = "merchantid", nullable = false, insertable = true, updatable = true, length = 22, precision = 0)
    @javax.persistence.Id
    public int getMerchantid() {
        return merchantid;
    }

    public void setMerchantid(int merchantid) {
        this.merchantid = merchantid;
    }

    private MerchantProfile merchantProfile;

    @OneToOne
    @JoinColumn(name = "merchantid", unique = true, nullable = false, updatable = true)
    public MerchantProfile getMerchantProfile() {
        return merchantProfile;
    }

    public void setMerchantProfile(MerchantProfile merchantProfile) {
        this.merchantProfile = merchantProfile;
    }

    private Collection<MerchantNexus> merchantNexusesByMerchantid;

    @javax.persistence.OneToMany(orphanRemoval = true)
    @JoinColumn(name="merchantid")
    public Collection<MerchantNexus> getMerchantNexusesByMerchantid() {
        return merchantNexusesByMerchantid;
    }

    public void setMerchantNexusesByMerchantid(Collection<MerchantNexus> merchantNexusesByMerchantid) {
        this.merchantNexusesByMerchantid = merchantNexusesByMerchantid;
    }
}

And the MerchantTaxData class:

@XmlRootElement(name = "merchantTaxData")
@XmlType(propOrder={"isTaxInfoKnown", "nexusList"})
public class MerchantTaxData {

    public MerchantTaxData() {
    }

    @XmlElement(name = "isTaxInfoKnown")
    private boolean isTaxInfoKnown;

    public boolean isTaxInfoKnown() {
        if (merchant == null)
            return false;
        return (1 == merchant.getIstaxinfoknown());
    }

    @XmlElementWrapper(name = "nexusList")
    @XmlElement(name = "nexus")
    private List<MerchantNexus> nexusList;

    public List<MerchantNexus> getNexusList() {
        return nexusList;
    }

    public void setNexusList(List<MerchantNexus> nexusList) {
        this.nexusList = nexusList;
    }

    private Merchant merchant;

    public Merchant getMerchant() {
        return merchant;
    }

    public void setMerchant(Merchant merchant) {
        this.merchant = merchant;
    }
}

What I’d like to get back is

{
    response: {
        merchantId: 92,
        email: "dev-catchall@blah.com",
        paymentMethods: [
            {paymentMethod: pm1},
            ...,
            {paymentMethod: pmN}
        ],
        merchantTaxData: {
            isTaxInfoKnown: true,
            nexusList: {
                nexus: [
                    {merchantid: 92,statecode: "CA"},
                    ...,
                    {merchantid: 92,statecode: "WA"}
                ]
            }
        }
    }
}

but what I get back is much more than that:

{
response: {
        merchantId: 0, 
        merchantTaxData: { 
            isTaxInfoKnown: true, 
            nexusList: {
                nexus: [
                    {merchantid: 92, statecode: "CA"}, 
                    ...,
                    {merchantid: 92, statecode: "WA"}
                ]
            }, 
            merchant: {
                merchantNexusesByMerchantid: [
                    {merchantid: 92, statecode: "CA"},
                    ...,
                    {merchantid: 92, statecode: "WA"}
                ],
                merchantProfile: {
                    email: "dev-mexp-catchall@pronto.com",
                    merchantid: 92
                },
                merchantId: 92
            }
        },
        merchant: {
            merchantNexusesByMerchantid: [
                {merchantid: 92, statecode: "CA"},
                ...,
                {merchantid: 92, statecode: "WA"}
            ],
            merchantProfile: {
                email: "dev-mexp-catchall@pronto.com",
                merchantid: 92
            }, 
            merchantid: 92
        }, 
        merchantProfile: {
            email: "dev-mexp-catchall@pronto.com", 
            merchantid: 92
        }
    }
}
  • 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-15T04:58:21+00:00Added an answer on June 15, 2026 at 4:58 am

    I should have had my annotations in front of the getters, not the variables.

    Beyond that, @SamiKorhonen or @user463324 were right in the comments that using @XmlAccessorType(XmlAccessType.NONE) was the way to go. I invited them to submit a real answer to the question, but neither ever did.

    I don’t want to get grief from the community for not accepting answers to my questions.

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
In my XML file chapters tag has more chapter tag.i need to display chapters
We're building an app, our first using Rails 3, and we're having to build

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.