为什么我的商品创建页面就一直报错,数据库里面也没插入任何数据。。
/** * @author Mib_du * @creat 2019-06-03-9:55 */ @Service public class ItemServiceImpl implements ItemService { //使用validator校验输入参数 @Autowired private ValidatorImpl validator; @Autowired private ItemDOMapper itemDOMapper; @Autowired private ItemStockDOMapper itemStockDOMapper; //itemmodel->itemdataobject private ItemDO itemDOconvertFromItemModel(ItemModel itemModel) { if(itemModel == null) return null; ItemDO itemDO = new ItemDO(); BeanUtils.copyProperties(itemModel,itemDO); itemDO.setPrice(itemModel.getPrice().doubleValue()); return itemDO; } //itemstockmodel->itemdataobject private ItemStockDO convertFromItemModel(ItemModel itemModel){ if(itemModel == null) return null; ItemStockDO itemStockDO = new ItemStockDO(); itemStockDO.setItemId(itemModel.getId()); itemStockDO.setStock(itemModel.getStock()); return itemStockDO; } @Override @Transactional public ItemModel createItem(ItemModel itemModel) throws BusinessException { //校验入参 ValidationResult result = validator.validate(itemModel); if(result.isHasErrors()){ throw new BusinessException(EnumBusinessError.PARAMETER_VALIDATION_ERROR,result.getErrorMsg()); } //转化itemmodel->dataobject ItemDO itemDO = this.itemDOconvertFromItemModel(itemModel); //写入数据库 itemDOMapper.insertSelective(itemDO); itemModel.setId(itemDO.getId()); ItemStockDO itemStockDO = this.convertFromItemModel(itemModel); itemStockDOMapper.insertSelective(itemStockDO); //返回创建完成的对象 return this.getItemById(itemModel.getId()); } @Override public List<ItemModel> listItem(Integer id) { return null; } @Override public ItemModel getItemById(Integer id) { ItemDO itemDO = itemDOMapper.selectByPrimaryKey(id); if(itemDO == null) return null; //操作获得库存数量 ItemStockDO itemStockDO = itemStockDOMapper.selectByItemId(itemDO.getId()); //将dataobject->model ItemModel itemModel = convertFromDataObject(itemDO,itemStockDO); return itemModel; } //dataobject --> model private ItemModel convertFromDataObject(ItemDO itemDO , ItemStockDO itemStockDO){ ItemModel itemModel = new ItemModel(); BeanUtils.copyProperties(itemDO,itemModel); itemModel.setPrice(new BigDecimal(itemDO.getPrice())); itemModel.setStock(itemStockDO.getStock()); return itemModel; } }
执行到
itemDOMapper.insertSelective(itemDO);
这行就会报错,浏览器会返回下面这个错误信息:
下面这个是报错的时候报错信息:
我调试了一下,发现断点之前的数据都是传进itemDO里了的,但是就是在执行inSertselective(itemDO)这句话时就会报错了。
有哪位大佬能帮我解答下吗 谢谢!!