我有 2 个实体类 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 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 就不行,我该如何帮助自己运行这个?或者有什么替代方法吗?
最佳答案
使用大写的第一个字符进行验证与 java bean 标准不匹配。 请更改属性名称或更改 getter 以获取 validated()
关于java - 无法使用 hibernate 执行 HQL 更新查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35857931/