openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kevin Sutter <>
Subject Re: How to persist duplicate of an entity?
Date Fri, 14 Jan 2011 15:18:13 GMT
There are so many variables that can come into play with a scenario like

If you are only looking to populate the database and you don't care about
the actual Entity objects, then you could just populate a single Entity
instance.  In a loop, persist and commit this entity, update the key and
repeat.  If you are using a Version field, then you'll also have to reset
that each time.

It all depends on the end game...  :-)


On Fri, Jan 14, 2011 at 8:52 AM, Henno Vermeulen <>wrote:

> The easiest way that I found to create a deep clone of an object graph is
> to use apache commons collections.
> SerializationUtils.deserialize(SerializationUtils.serialize(object)).
> Can of course also be used for a simple entity without relations. In anyway
> you have to watch out that you still set all primary keys to null. (May also
> not be most performant way.)
> Regards,
> Henno Vermeulen
> Huize Molenaar
> -----Oorspronkelijk bericht-----
> Van: Ognjen Blagojevic []
> Verzonden: vrijdag 14 januari 2011 15:12
> Aan:
> Onderwerp: How to persist duplicate of an entity?
> Hi,
> Is there an easy way to create duplicate of an entity?
> I want to read entity from the DB, and then persist (almost) identical
> copy. Every field should be the same, except primary key.
> I know I could probably use BeanUtils.copyProperties, but is there
> OpenJPA preffered way to do the duplication?
> Regards,
> Ognjen

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message