Hi,
I need to create clones of some of my JPA entities, and modify some
of their fields. My plan was to:
1. load some JPA entities: o = em.find(Person.class, id);
2. detach them with em.detach(o)
3. update a few fields and set @Id to null to make JPA create new rows
instead of updating the old ones
4. em.merge(o)
But this fails since I am not allowed to update the @Id field:
Caused by: Exception [EclipseLink-7251] (Eclipse Persistence Services
- 2.0.1.v20100213-r6600):
org.eclipse.persistence.exceptions.ValidationException
Exception Description: The attribute [id] of class [com.bzz.Person] is
mapped to a primary key column in the database. Updates are
not allowed.
at org.eclipse.persistence.exceptions.ValidationException.primaryKeyUpdateDisallowed(ValidationException.java:2400)
QUESTION: is there any way around this? Is there some JPA -related
strategy that I could use to conveniently clone JPA entities?
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users