jeesite4保存实体保存不了的情况

 在我新增调用了保存方法之后我的数据库里面并没有数据,没有数据,看下后台打印的sql,是不是执行了update,确实是执行了update

entity如果setid了,你需要设置  entity.setisnewrecord(true) 标记为新记录才可以,否则你不能调用save,可以改为insert

修改后

/**
	 * 保存py_narcotics
	 */
	@RequiresPermissions("py:pyNarcotics:edit")
	@PostMapping(value = "save")
	@ResponseBody
	public String save(@Validated PyNarcotics pyNarcotics) {
		//处理图片上传		
		if(pyNarcotics.getId() == null || pyNarcotics.getId().equals("")){
			pyNarcotics.setId(IdGen.nextId());
			pyNarcotics.setIsNewRecord(true);
		}
		FileUploadUtils.saveFileUpload(pyNarcotics.getId(), "pyNarcotics_image");	
		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMM");
		String yearMonth = sdf.format(new Date());
		String url=new String();
		List<FileUpload> fileUpload = FileUploadUtils.findFileUpload(pyNarcotics.getId(), "pyNarcotics_image");
		for(FileUpload fu:fileUpload){
			url = "/userfiles/fileupload/" + yearMonth +"/" +fu.getFileEntity().getFileId()+".jpg";
		}
		pyNarcotics.setPhoto(url);
		
//		pyNarcoticsService.insert(pyNarcotics);
		pyNarcoticsService.save(pyNarcotics);
		return renderResult(Global.TRUE, text("保存成功!"));
	}

猜你喜欢

转载自blog.csdn.net/qq_37725560/article/details/93718893