BeanUtils.cloneBean() deep copy

拜拜、爱过 提交于 2019-12-09 07:55:38

问题


If all the objects within the bean implement Serializable interface, will BeanUtils.cloneBean() do a deep copy?


回答1:


No, cloneBean() does shallow copy only. If you want deep copy. You may refer this link which has technique to do deep copy.




回答2:


Use SerializationUtils.clone method from the Apache Commons Lang for the deep copy. It copies the entire class hierarchy.

SerializationUtils.clone(object);



回答3:


There is also another java library which supports both shallow cloning and deep cloning. It offers deep cloning without the need to implement Serializable.

Here



来源:https://stackoverflow.com/questions/9264066/beanutils-clonebean-deep-copy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!