I am writing a custom clone method for each entity. for deep copy is there a way to detect circular references or do I have to manually figure it out and restrict cloning to be unidirectional instead of bidirectional.
For example we use hibernate an hence a User object has a reference to Address and Address has a reference to User. Trying to see if doing a deep copy of Address as well as User is possible without running into circular reference issues
To implement this, you need a Map of references to already cloned objects. We implemented deep clone something like this:
In our entity base class: