今天用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'?
这是因为SpringDataJPA自定义扩展方法,方法名中的字段和数据库字段不一致造成的。
比如我的想法是根据图片的ID来删除这张图片,但是在pojo
中并没有imageId
,而只有id,映射不过去,所系改成一致即可。
当然使用SpringDataJPA的提供的方法也可以
imageDao.deleteById();
© 版权声明
THE END
暂无评论内容