public User update(User user) {
List<UserOrganizationJob> localUserOrganizationJobs = user.getOrganizationJobs();
for (int i = 0, l = localUserOrganizationJobs.size(); i < l; i++) {
UserOrganizationJob localUserOrganizationJob = localUserOrganizationJobs.get(i);
//设置关系 防止丢失 报 A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance
localUserOrganizationJob.setUser(user);
UserOrganizationJob dbUserOrganizationJob = findUserOrganizationJob(localUserOrganizationJob);
if (dbUserOrganizationJob != null) {//出现在先删除再添加的情况
dbUserOrganizationJob.setJobId(localUserOrganizationJob.getJobId());
dbUserOrganizationJob.setOrganizationId(localUserOrganizationJob.getOrganizationId());
dbUserOrganizationJob.setUser(localUserOrganizationJob.getUser());
localUserOrganizationJobs.set(i, dbUserOrganizationJob);
}
}
return super.update(user);
}