Reputation: 393
I needed to clone the hybris bean "ProductData", and I couldn't find something OOTB from Hybris that helps with this.
And since hybris beans don't implement Cloneable and don't have constructors, it seems to me that there are only two ways left, either by creating a custom cloning method witch require a lot of dev, or through serialization/deserialization.
Is there another way to do that? and does Hybris provides something OOTB for this? or else is the serialization/deserialization a good approach (in term of performance) for this since there is the SerializationUtils from apache that I can use?
Upvotes: 0
Views: 831
Reputation: 1248
Hi You can directly Inject dataMapper bean in your controller or in service.
import de.hybris.platform.webservicescommons.mapping.DataMapper;
@Autowired
private DataMapper dataMapper;
dataMapper.map(e, ProductData.class)
Upvotes: 1
Reputation: 196
Based on which hybris version you use, you can also use ma.glasnost.orika.MapperFactory like:
MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
MapperFacade mapper = mapperFactory.getMapperFacade();
ProductData clonedData = mapper.map(productData, ProductData.class);
Upvotes: 1