1、在实体类中实现Serializable,Cloneable两个接口,如下:
public class ScSchedule implements Serializable,Cloneable{
}
2、在实体类中重载clone方法,如下:
@Override
public ScSchedule clone() throws CloneNotSupportedException {
ScSchedule newSchedule=(ScSchedule) super.clone();
newSchedule.details=null;
newSchedule.id=null;
return newSchedule;
}
3、Service方法里添加方法,如下:
public ScSchedule clone(ScSchedule scSchedule) throws CloneNotSupportedException {
return scSchedule.clone();
}
4、调用Service方法即可。