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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T21:43:42+00:00 2026-06-07T21:43:42+00:00

I am trying to map two JavaBean structures (here simplified): package foo; public class

  • 0

I am trying to map two JavaBean structures (here simplified):

package foo;
public class Container {
    private List<Item> items;
    public List<Item> getItems() { return items; }
    public void setItems(List<Item> items) { this.items = items; }
}

public class Item {
    private String message;
    public String getMessage() { return message; }
    public void setMessage(String message) { this.message = message; }
}

In addition I have equal Beans with the same properties in package bar and do the mapping between the two like

ModelMapper mapper = new ModelMapper();
bar.Container barContainer = mapper.map(fooContainer, bar.Container.class);

where the source fooContainer contains a list of items some of which have the property message set to a String and some of them have null as property value.

In the mapping result I discover that the list of foo.Item seems to be correctly mapped to a list of bar.Item also the first message properties are mapped correctly. But after the first item with a null value of the message property all message property values of hte following items are mapped to null regardless of the content of the source properties.

With debugging I found out why:
Once the destination property value is null the message property path is marked as shaded in MappingEngineImpl:207 and then ignored for the subsequent items in MappingEngineImpl:142.

Is this a bug of moddelmapper or do I have to configure modelmapper in another way to enable mapping of list of bean properties?

  • 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-07T21:43:44+00:00Added an answer on June 7, 2026 at 9:43 pm

    The definitely looks like a bug to me. I actually encountered the very same issue with my own use of ModelMapper which is how I found this question.

    Shading paths that are null seems dangerous since the same context is used to map other objects. I have taken this feature out and it seems to work as expected.

    I created an issue on the ModelMapper page around this bug:
    http://code.google.com/p/modelmapper/issues/detail?id=19

    Also, I fixed the issue and posted it to GitHub. I have made a pull request and hopefully it will be incorporated into the next version of ModelMapper:
    https://github.com/chrisdail/modelmapper

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

Sidebar

Related Questions

I have a public facing interface that I'm trying to map two different enumerations
I am trying to insert an item, into a map, which holds two other
I am trying to create a map using two arrays. Here is the code:
I am trying to map a legacy database here and I'm running into a
I am trying to map the collection for two days without success. I also
inspired by this answer I'm trying to map a property on a model class
So I have this two classes: public class PhysicalTest { public int ID {
I am trying to calculate the distance between two map point using Google Map
I have two activities in my application. The first is a map with item
I'm trying to map two domain entities to the same table. We're doing a

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.