Re: clone object

2018-07-27 Thread Mark Struberg
In practice this is likelymuch more complicated. Where are the boundaries? If you have a Person which has a relation to a Company, then I assume you do not want to also clone the whole Company, right? ;) But of course, the n Address rows probably should get cloned? Do you see what I mean? This

Re: clone object

2018-07-27 Thread Matthew Broadhead
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

Re: clone object

2018-07-27 Thread Albert Lee
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:

Re: clone object

2018-07-27 Thread Albert Lee
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 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? > >

clone object

2018-07-27 Thread Matthew Broadhead
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