Java 无法使用hibernate执行HQL更新查询
我有两个实体类BatchFile和BatchFileRecord。运行HQL查询时,会出现以下错误: org.hibernate.QueryException:无法解析属性:IsValidated of:com.cc.myApp.dal.models.BatchFileRecordJava 无法使用hibernate执行HQL更新查询,java,mysql,spring,hibernate,orm,Java,Mysql,Spring,Hibernate,Orm,我有两个实体类BatchFile和BatchFileRecord。运行HQL查询时,会出现以下错误: org.hibernate.QueryException:无法解析属性:IsValidated of:com.cc.myApp.dal.models.BatchFileRecord Session sess = sessionFactory.getCurrentSession(); sess.beginTransaction(); String sb="update BatchFile bf s
Session sess = sessionFactory.getCurrentSession();
sess.beginTransaction();
String sb="update BatchFile bf set bf.isCheck = 0 where bf.Id in(selectb.BatchFileId from BatchFileRecord b where b.BatchId = "+batchId+" and b.IsValidated = 0) and bf.BatchId = "+batchId;
Query query = sess.createQuery(sb);
int numUpdated = query.executeUpdate();
System.out.println("Rows affected: " + numUpdated);
直接使用mysql它工作得很好,但使用hibernate它不工作,我怎样才能帮助自己运行它呢?或者有其他方法可以这样做吗?验证第一个大写字符与JavaBean标准不匹配。
请更改属性名称或将getter更改为getIsvalidated()这看起来像是HQL和纯SQL的混合。您能在问题中包括实体类吗?当您使用实体管理器时,必须使用实体类的属性名而不是DB表的列名。您能用getter和setter发布BatchFile bean类吗