1、实体之间的复制。
public Schedule addSchedule(Schedule schedule) throws SystemException {
long scheduleId = this.counterLocalService.increment();
Schedule newSchedule = this.createSchedule(scheduleId);
String[] ignoreProperties = new String[]{"new","scheduleId","primaryKey","primaryKeyObj"};
BeanUtils.copyProperties(schedule, newSchedule,ignoreProperties);
newSchedule.setPrimaryKey(scheduleId);
return super.addSchedule(newSchedule);
}
注意 ,这个是 拷贝,但是其中某些字段除外。
String[] ignoreProperties = new String[]{"new","scheduleId","primaryKey","primaryKeyObj"};
这是必须的。
其实,阿帕奇也有这个工具类,但是他不支持date类型的转换。