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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T00:58:36+00:00 2026-06-17T00:58:36+00:00

Disclaimer: the same question has already been asked here Mapping deep properties with intermediate

  • 0

Disclaimer: the same question has already been asked here Mapping deep properties with intermediate collections in dozer, but it has no accepted answer (and no proper answer for my case).

So the question. I have a realm composed by a ComplexObject like the following

public class ComplexObject {
  private Set<AnotherComplexObject> inner;
  ... //other fields, setters and getters
}
public Class AnotherComplexObject {
  private String property;
  ... //other fields, setters and getters
}

Now, I am mapping ComplexObject to Target, where Target has a Set<String> property.

public class Target {
  private Set<String> targetString;
  ... //other fields, setters and getters
}

I want to map each ComplexObject inner.property onto one Target targetString. Something that semantically looks like (this does not work of course, property is not a member of Set and Dozer generates a MappingException):

<mapping>
  <class-a>ComplexObject</class-a>
  <class-b>Target</class-b>
  <field>
    <a>inner.property</a>
    <b>targetString</b>
  </field>
</mapping>

I can accomplish my goal if I modify the toString method of AnotherComplexObject to

public class AnotherComplexObject {
  public String toString(){
    return property;
  }
}

Then, Dozer will detect the source Set is of “type” AnotherComplexObject while the target Set is of String and will use the method toString during the conversion. Unfortunately, this is not quite a solution since I will need a method in my POJO just to let Dozer doing the conversion.

What does work is to write a custom converter which overrides the convert method to check if source is a Set and then supposes the objects in the set are AnotherComplexObject and doing the conversion from this point on but somehow I feel this is not best nor the more elegant solution.
Any other idea about how to solve this problem?

  • 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-17T00:58:38+00:00Added an answer on June 17, 2026 at 12:58 am

    Maybe my answer can be useful for you:

    I think, you can write such a mapping

    <mapping>
      <class-a>Baz</class-a>
      <class-b>Target</class-b>
      <field>
        <a>foos</a>
        <b>fooStrings</b>
      </field>
    </mapping>
    
    <custom-converters> 
      <converter type="CustomFooConverter">
        <class-a>
          Foo
        </class-a>
        <class-b>
          String
        </class-b>
      </converter>
    </custom-converters>
    

    And implement CustomFooConverter to get string field of foo and return it as a String.

    I think you can post a feature request to support mapping to primitives as

    <mapping>
      <class-a>Foo</class-a>
      <class-b>String</class-b>
      <field>
        <a>string</a>
      </field>
    </mapping>
    

    into Dozer GitHub

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

Sidebar

Related Questions

DISCLAIMER: I'm almost sure that I've seen the same question before but I can't
The Disclaimer First of all, I know this question (or close variations) have been
Disclaimer: This is not actually a programming question, but I feel the audience on
Disclaimer: I understand the question is very basic, but I could not find the
Disclaimer: this question is driven by my personal curiosity more than an actual need
Disclaimer: I am using ExtJS 3, but I don't think it's very relevant to
Disclaimer : I'm quite a novice to RoR, but not with Ruby (if that
Disclaimer: I am still learning SQL so I apologize if my question comes off
Disclaimer, I'm not a PHP programmer, so you might find this question trivial. That's
Disclaimer When I wrote this question I was wrong about the behavior of 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.