'Pojo Conversion with HibernateMapping & Jaxb

I have two Pojo classes, one for hibernate mapping and one for jaxb. So I get a List<CarA> using Criteria.list() and I would like to transform it into a List<CarB> in order to send it back to my client as a SOAP message.

Would you have any idea how to do the conversion from CarA to CarB?

My list contains more than 100 elements and the construction gets expensive very fast.

I wish I didn't have to build a list from A to Z.

Thanks for your help



Solution 1:[1]

you can use model mapper libraray : https://www.baeldung.com/java-modelmapper

example you can do :

 List<Carb> lb = new ArrayList();
for (Cara a : la )
    lb.add(mapper.map(a, Carb.class))

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Elie Azoury