The need to create an object clone came up at some point in our project and having heard that interfaces such as Cloneable
and the like aren't really the best thing to use so as a fast solution I thought of just querying the database to receive a copy of that object (the moment the cloning happens is right after an upsert
statement). Then I also thought of a hacky clone method using object serialization-deserialization. What would you choose?
Note that I am using MongoDB as a repository with Spring Data and in the future we are thinking of adding Spring's Caching mechanism in our repositories.