i have a complicated object with a large number of children, each child possibly having their own large number of children.  what would be great in OpenJPA is if you could, say, detach an object and run a command which would null all @Id and @Version fields in the detached Object and all its descendants.  i suppose it has to be done manually though...

On 27/07/18 15:52, Albert Lee wrote:
If the java object implements Serializable or Clonable, you can
writeObject/readObject to clone to a new entity.  The new object will be
detached and you can reset the id and version as you wish.


On Fri, Jul 27, 2018 at 8:39 AM, Matthew Broadhead <
matthew.broadh...@nbmlaw.co.uk.invalid> wrote:

i don't think it would clear the id and version fields?  do you mean using
SerializationUtils clone?
https://commons.apache.org/proper/commons-lang/apidocs/org/
apache/commons/lang3/SerializationUtils.html


On 27/07/18 15:09, Albert Lee wrote:

If the entity is serializable have you try writing it out and read it back
to a new object?

On Fri, Jul 27, 2018, 6:05 AM Matthew Broadhead
<matthew.broadh...@nbmlaw.co.uk.invalid> wrote:

is there a way to deep clone a JPA object automatically?  i.e. to copy
all the parameters and children but clear the id and version fields?

i saw that it is possible to do em.detach(object); and then reset the id
and version but by the time i have done that i may as well have written
a full copy function.




Reply via email to