克隆 hybris bean 的最佳方法是什么?
the best way to clone hybris beans?
我需要克隆 hybris bean“ProductData”,但我无法从 Hybris 中找到可以帮助解决此问题的 OOTB。
并且由于 hybris bean 没有实现 Cloneable 并且没有构造函数,在我看来只有两种方法,要么创建自定义克隆方法 需要大量开发人员, 或者通过 serialization/deserialization.
还有其他方法吗? Hybris 是否为此提供了一些 OOTB?或者 serialization/deserialization 是一个很好的方法(就性能而言),因为我可以使用来自 apache 的 SerializationUtils?
根据您使用的 hybris 版本,您还可以使用 ma.glasnost.orika.MapperFactory,例如:
MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
MapperFacade mapper = mapperFactory.getMapperFacade();
ProductData clonedData = mapper.map(productData, ProductData.class);
您好,您可以直接在控制器或服务中注入 dataMapper bean。
import de.hybris.platform.webservicescommons.mapping.DataMapper;
@Autowired
private DataMapper dataMapper;
dataMapper.map(e, ProductData.class)
我需要克隆 hybris bean“ProductData”,但我无法从 Hybris 中找到可以帮助解决此问题的 OOTB。
并且由于 hybris bean 没有实现 Cloneable 并且没有构造函数,在我看来只有两种方法,要么创建自定义克隆方法 需要大量开发人员, 或者通过 serialization/deserialization.
还有其他方法吗? Hybris 是否为此提供了一些 OOTB?或者 serialization/deserialization 是一个很好的方法(就性能而言),因为我可以使用来自 apache 的 SerializationUtils?
根据您使用的 hybris 版本,您还可以使用 ma.glasnost.orika.MapperFactory,例如:
MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
MapperFacade mapper = mapperFactory.getMapperFacade();
ProductData clonedData = mapper.map(productData, ProductData.class);
您好,您可以直接在控制器或服务中注入 dataMapper bean。
import de.hybris.platform.webservicescommons.mapping.DataMapper;
@Autowired
private DataMapper dataMapper;
dataMapper.map(e, ProductData.class)