hop
hop

Reputation: 2558

BeanUtils.cloneBean() deep copy

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

Upvotes: 24

Views: 51516

Answers (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

Upvotes: 1

kosa
kosa

Reputation: 66677

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

Upvotes: 9

Vikas Chowdhury
Vikas Chowdhury

Reputation: 775

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

SerializationUtils.clone(object);

Upvotes: 41

Related Questions