Search code examples
javaspringspring-bootmappermodelmapper

Modelmapper cannot map the whole model?


I have a problem with mapping a little bit more complex object, actually it maps it but only half of the object.

The object is:

{
"firstName": "John",
"lastName": "John",
"description": "Its running",
"personalWebsite": "www.asd.com",
"country": "USA",
"email": "[email protected]",
"pictureBindingModel": {
    "pictureUrl": "john.com"
},
"languageBindingModels": [{
    "language": "Spanish",
    "languageLevelBindingModel": {
        "languageLevel": "Advanced"
    }
}],
"workSphereBindingModels": [{
        "workSphere": "IT",
        "subSphereBindingModels": [{
            "subSphere": "Programming"
        }]
}],
"skillBindingModels": [{
    "skill": "Spring data",
    "skillLevelBindingModel": {
        "skillLevel": "Beginner"
    }
}],
"educationBindingModels": [{
    "countryBindingModel": {
        "country": "USA"
    },
    "universityName": "Harvard",
    "titleTypeBindingModel": {
        "titleType": "Ph.D"
    },
    "educationSubject": "Java programming",
    "graduationYear": 2020
}],
"certificateBindingModels": [{
    "certificateSubject": "Spring master",
    "awardedFrom": "Harvard",
    "graduationYear": 2021
}]
}

Have a lot of nested objects which are Sets and it does the job halfway. I use "MatchingStrategies.LOOSE".

Also the binding model is filled correctly and the structure is the same as the entity!

The 3 not mapped fields:

enter image description here


Solution

  • The problem is educationBindingModels ,certificateBindingModels is Education as well as certificates in your Pojo it should be same name . Name and mapping object are different it should be same .