I can’t get a container from the class field using reflection. I tried the method below, but got an exception: I don’t want to use methods of copying via serialization, I’m interested in reflection. Answer You are doing this for training I hope? If not then use some opensource library, it’s a lot harder than you think – check this.
Tag: deep-copy
How to deep copy a Hibernate entity while using a newly generated entity identifier
I’m using a relational DB using a single column pk with a few nested tables. I need to add a simple archiving to my project. The archiving only happens when the application reaches a particular state, so what I was hoping to do was copy my existing hibernate object into a new instance where the new instance would be saved
How to clone ArrayList and also clone its contents?
How can I clone an ArrayList and also clone its items in Java? For example I have: And I would expect that objects in clonedList are not the same as in dogs list. Answer You will need to iterate on the items, and clone them one by one, putting the clones in your result array as you go. For that