I have a JPA entity already persisted in the database.
I would like to have a copy of it (with a different id), with some fields modified.
What is the easiest way to do this? Like:
- setting it's
@Id
field to null
and persisting it will work?
- will I have to create a clone method for the entity (copying all fields except the
@Id
)?
- is there any other approach (like using a cloning framework)?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…