문제

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

도움이 되었습니까?

해결책

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

다른 팁

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

SerializationUtils.clone(object);

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top