BeanUtils.cloneBean() deep copy

前端 未结 3 1427
北海茫月
北海茫月 2021-02-12 13:57

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

相关标签:
3条回答
  • 2021-02-12 14:05

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

    0 讨论(0)
  • 2021-02-12 14:05

    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

    0 讨论(0)
  • 2021-02-12 14:26

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

    SerializationUtils.clone(object);
    
    0 讨论(0)
提交回复
热议问题