我正在使用spring-boot,spring data jpa,我有一个场景,比如记录和更新记录的状态。
Project updateProject =null;
private void changeStatusOfProject(Integer projectId, String statusJobSchedule) {
logger.info("changeStatusOfProject "+STATUS + statusJobSchedule);
Project p =projectDao.findOne(pid);
updateProject = new Project();
updateProject.setProjectId(p.getProjectId());
updateProject.setPText(p.getPText());
updateProject.setEcommDisplayFlag(p.getEcommDisplayFlag());
updateProject.setUpdatedDate(new Date());
updateProject.setUpdatedBy("Chandu");
logger.info("p id : " +p.getpID());
if (statusJobSchedule.equalsIgnoreCase("Completed")) {
updateProject.setActive("N");
} else {
updateProject.setActive("Y");
}
updateProject.setExecutionStatus(statusJobSchedule);
projectDao.save(updateProject);
}
我也没有得到例外。
追踪2:
projectDao是jparepositarty的实现类
private void changeStatusOfProject(Integer projectId, String statusJobSchedule) {
logger.info("changeStatusOfProject "+STATUS + statusJobSchedule);
Project project =projectDao.findOne(projectId);
if (statusJobSchedule.equalsIgnoreCase("Completed")) {
project.setActive("N");
} else {
project.setActive("Y");
}
question.setExecutionStatus(statusJobSchedule);
questionBankDao.save(project);
}
答案 0 :(得分:0)
我曾经有过类似的问题,对我来说这是因为它被缓存了。
我通过将@Cacheable(false)
添加到我的实体类来修复它。
答案 1 :(得分:0)
我的代码没有看到任何错误,但请尝试这种方式
private void changeStatusOfProject(Integer projectId, String statusJobSchedule) {
logger.info("changeStatusOfProject "+STATUS + statusJobSchedule);
Project p =projectDao.findOne(pid);
p.setUpdatedDate(new Date());
p.setUpdatedBy("Chandu");
logger.info("p id : " +p.getpID());
if (statusJobSchedule.equalsIgnoreCase("Completed")) {
p.setActive("N");
} else {
p.setActive("Y");
}
p.setExecutionStatus(statusJobSchedule);
projectDao.save(p);
}