3

I have the following Entity Classes:

class Provider{
    private String providerId;
    private String identificationNumber;
    private Account account;

  // Setters, Getters and toString
}

class Account {
    private String name;
    private String lastname;
    private String email;

   // Setters, Getters and toString
}

DTO:

class ProviderDTO{
    private String providerId;
    private String identificationNumber;
    private String accountName;
    private String accountLastname;

   //Setters, Getters and toString
 }

If I try to map my DTO to the Provider entity using (MatchingStrategies.STRICT):

Provider provider = modelMapper.map(providerDTO,Provider.class);

provider.getAccount().getName() is null and provider.getAccount().getName() is null

But if I using a (MatchingStrategies.STANDARD): Works perfectly....

provider.getAccount().getName() is not null and provider.getAccount().getName() is not null

My question is: how should I name the properties of my DTO so that modelmapper works in STRICT mode?

I would like to receive an explanation of how strict mode works, because I did not find examples, even on the official modelmapper website. Many thanks!

AlejoDev
  • 4,345
  • 9
  • 36
  • 67

1 Answers1

3

The STRICT matching strategy is not supporting this kind of mapping (hierarchical -> flat or flat -> hierarchical).

Please refer the docs here: matching strategy and the unit test for STRICT matching strategy: StrictMatchingStrategyTest

Chun Han Hsiao
  • 251
  • 1
  • 7