What I have is an entity bean e.g. Entity (EJB 3) that keeps same type children in an ArrayList<Entity>, his parent <Entity> and a relation to another entity <Users>. Users can own many Entities, and vice-versa (many to many).
What I would like to do is override Entity.clone() (or have a new method) to deep-copy Entity along with clones of children , belonging to the same parent and being assigned to the already existing users.
I have set up the clone method to create a clone of the Entity (a new Entity that is), and then fill it with clones of the children entities within a foreach loop.
But this gives me a concurrent modification exception and I end up with just a clone of the initial Entity bean without its children.
My question is:
Is what I want to do feasible at all or should I manage deep copying from e.g. a Facade? If it is feasible, could you direct me please to something to read or give me a couple of hints, because up to now I do the cloning via a facade and it has become a major burden in my application.
Thanks in Advance!!
pataroulis