jeudi 21 juillet 2016

How to parse DTO to Pojo objects

Well, I'm trying to parse objects and I'm having so much issues. My classes are like this:

-Entidad-

public class Entidad{

    private Long codEntidad;
    private Set<Comunicacion> comunicacion;


    /*------------ Getter and Setters --------------*/

}

-Comunicacion-

public class Comunicacion {

    private Entidad entidad;
    private Long codComunicacion;

    /*------------ Getter and Setters --------------*/

}

I need to parse to DTO objects:

-EntidadDTO-

public class EntidadDTO{

    private Long codEntidad;
    private Set<ComunicacionDTO> comunicacionDto;


    /*------------ Getter and Setters --------------*/

}

-ComunicacionDTO-

public class ComunicacionDTO {

    private EntidadDto entidadDto;
    private Long codComunicacion;

    /*------------ Getter and Setters --------------*/

}

I tried to use:

BeanUtils.copyProperties(entidad, entidadDto);

It seems that the parse is success but the property entidadDto.getComunicacionDto(); is a hashMap of Comunicacion (not ComunicacionDTO)

Should I try to make a custom parse with reflection?

Also I'd like to use this to parse more objects with a similar structure. Thanks!





Aucun commentaire:

Enregistrer un commentaire