Answers for "ModelMapper skip a field codegrepper"

1

ModelMapper skip a field codegrepper

UserEntity user =new UserEntity();
        ModelMapper modelMapper = new ModelMapper();
        modelMapper.getConfiguration().setAmbiguityIgnored(true);
        PropertyMap<UserDTO,UserEntity > clientPropertyMap= new PropertyMap<UserDTO,UserEntity>() {
            @Override
            protected void configure() {
                skip(destination.getFatherDetailsEntity().getUser());
                skip(destination.getFirstName());
            }
        };
        modelMapper.addMappings(clientPropertyMap);
        modelMapper.map(request, user);

OUTPUT: UserEntity{userId=0, firstName='null', lastName='Ahsan', userName='ArslanAhsan2', creationTime=null, fatherDetailsEntity=FatherDetailsEntity{id=null, fatherName='ABCD', cnic='38201'}}
Posted by: Guest on September-24-2021
0

ModelMapper skip a field codegrepper

ModelMapper modelMapper = new ModelMapper();
        modelMapper.addMappings(new PropertyMap<UserDTO, UserEntity>() {
            @Override
            protected void configure() {
                skip(destination.getFatherDetailsEntity().getUser());
            }
        });
        user=modelMapper.map(request, UserEntity.class);

        System.out.println("Request=>" +user);
OUTPUT: UserEntity{userId=0, firstName='null', lastName='Ahsan', userName='ArslanAhsan2', creationTime=null, fatherDetailsEntity=FatherDetailsEntity{id=null, fatherName='ABCD', cnic='38201'}}
Posted by: Guest on September-24-2021

Browse Popular Code Answers by Language