hibernate:Not all named parameters have been

东方咖啡屋 2020-04-19

出错信息

update Project p set p.returnCount=:returnCount,p.passTime =:passTime, p.returnTime=:returnTime where p.id=:id

Not all named parameters have been set: [passTime]

passTime是Date数据类型,现在需要设置成null,只需要把hql里面改对象设置为null

public void updateReturnCount(Project project){
        try {
            String hql = "update Project p set p.returnCount=:returnCount,p.passTime=null, p.returnTime=:returnTime where p.id=:id";
            Parameter param = new Parameter();
            param.put("returnCount",project.getReturnCount());
            // 如果需要前台设置驳回时间,替换成project.getReturnTime()
            param.put("returnTime",DateUtils.getSysDate());
            param.put("id",project.getId());
            int effected = projectDao.batchExecute(hql, param);
            log.info("projectId:{},更新后returnCount:{},驳回时间:{},更新{}条数",
                    project.getId(),project.getReturnCount(), DateUtils.dateFormat(project.getReturnTime()),effected);
        }catch (Exception e) {
            log.error("项目驳回出错:{}",e);
        }
    }

相关推荐

JF0 / 0评论 2019-11-03