Domanda

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

È stato utile?

Soluzione

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

Altri suggerimenti

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top