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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:14:17+00:00 2026-06-09T05:14:17+00:00

How do you map a single field into a List / Collection in Dozer?

  • 0

How do you map a single field into a List / Collection in Dozer?

class SrcFoo {
    private String id;
    private List<SrcBar> bars;
}

class SrcBar {
    private String name;
}

Here are my destination objects:

class DestFoo {
    private List<DestBar> destBars;
}

class DestBar {
    private String fooId; // Populated by SrcFoo.id
    private String barName;
}

I want all DestBar.fooId (entire list of DestBars) to be populated with SrcFoo.id

This question is similar to this one posted here, expect I want to map my single field to every item in the list. Dozer: map single field to Set

I tried the following, but it only populated DestBar.fooId for the first item in the list.

<mapping> 
     <class-a>SrcFoo</class-a> 
     <class-b>DestFoo</class-b> 
     <field>
         <a>bars</a>
         <b>destBars</b>
     </field> 
     <field>
         <a>id</a>
         <b>destBars.fooId</b> <!-- same affect as destBars[0].fooId ? -->
     </field> 
</mapping>
  • 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-09T05:14:18+00:00Added an answer on June 9, 2026 at 5:14 am

    Dozer does not support that type of mapping. In order to do that type of mapping, you would have to know the indexes on your Collection (static mapping).
    This a Job for a custom converter, Create a converter of String to List (of DestBar) like this:

    public class YourConverter extends DozerConverter<String, List>
    

    Implement the mapping logic in your converter (Just set the String Id where required) and configure your dozer file like this:

    <mapping> 
         <class-a>SrcFoo</class-a> 
         <class-b>DestFoo</class-b> 
         ...
         <field custom-converter="yourpackage.YourConverter">
             <a>id</a>
             <b>destBars</b>
         </field> 
    </mapping>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying idiomatically merge multiple maps into a single map using clojure. Input
Map<String, List<String>> words = new HashMap<String, List<String>>(); List<Map> listOfHash = new ArrayList<Map>(); for (int
I have this class hierachy: class A { private String a1; private Class B
Is it possible to map a table column to a class field instead to
I have a field declared as a Map<MyEnum, String> , which is audited. When
I need to map a single fixed sized array array to multiple properties. For
When I use in my application: <resources location=/resources/favicon.ico mapping=/favicon.ico /> to map out single
I have a single annotation on a map view. I can select it programmaticly,
I'd like to show a single specific local business on a google map (API
using c++ std's unordered_map i want to map an integer triplet to a single

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.