项目名:patentFlowManagementProject
如果不加事务注解,数据插入失败而且无任何报错,很诡异。
@Override
@Transactional
public void joinPrefecture(String prefectureId, String userId) throws Exception {
Prefecture prefecture = findById(Prefecture.class, prefectureId);
Applicant applicant = findById(Applicant.class, userId);
PrefectureApplicant prefectureApplicant = new PrefectureApplicant();
prefectureApplicant.setId(UUIDGenerator.randomUUID());
prefectureApplicant.setType("applying");
prefectureApplicant.setPrefecture(prefecture);
prefectureApplicant.setApplicant(applicant);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
prefectureApplicant.setTime(simpleDateFormat.format(new Date(System.currentTimeMillis())));
System.out.println(prefectureApplicant.toString());
System.out.println(prefectureApplicant.getId());
System.out.println(prefectureApplicant.getTime());
System.out.println(prefectureApplicant.getType());
save(prefectureApplicant);
}