org.hibernate.QueryException: could not resolve property的解决办法

could not resolve property: cust_name of: domain.Customer
could not resolve property: cust_name of: domain.Customer; nested exception is org.hibernate.QueryException: could not resolve property: cust_name of: domain.Customer

首先看看报的错。
重点在于“cust_name”这是数据库中的一个字段,报的错是无法解析这个字段,Idea能自动生成持久化类和对应的配置文件,所以先排除配置文件出错。进入配置文件会发现在这里插入图片描述

它自动去除了下划线。因此如下图所写的为错误示范,也就是本次报错的原因,应该将配置属性名和orm映射名称相同
在这里插入图片描述

下划线去掉使用Customer类中的属性名就正确了。

猜你喜欢

转载自blog.csdn.net/weixin_43184769/article/details/82817276