PropertyReferenceException:No property ID found for type Image! Did you mean 'id' 错误解决办法

今天用springboot继续写着博客,使用SpringDataJPA操作数据库的时候,出现了这样一个问题

java.lang.IllegalArgumentException: Failed to create query for method public abstract com.beiwangshan.blog.pojo.Image com.beiwangshan.blog.dao.ImageDao.findOneByID(java.lang.String)! No property ID found for type Image! Did you mean 'id'?

PropertyReferenceException:No property ID found for type Image! Did you mean 'id' 错误解决办法-1

这是因为SpringDataJPA自定义扩展方法,方法名中的字段和数据库字段不一致造成的。

比如我的想法是根据图片的ID来删除这张图片,但是在pojo中并没有imageId,而只有id,映射不过去,所系改成一致即可。

PropertyReferenceException:No property ID found for type Image! Did you mean 'id' 错误解决办法-2

当然使用SpringDataJPA的提供的方法也可以

imageDao.deleteById();

© 版权声明
THE END
点赞0 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容