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 wa
ModelMapper lib can be used for this purpose.
public MyEntity clone(MyEntity myInstance) { MyEntity newInstance = new MyEntity(); new ModelMapper().map(myInstance, newInstance); return newInstance; }
just add the maven dependency
org.modelmapper modelmapper 2.3.2