简体   繁体   English

无法使用休眠模式执行HQL更新查询

[英]Unable to execute HQL update query using hibernate

I have 2 entity classes BatchFile and BatchFileRecord. 我有2个实体类BatchFile和BatchFileRecord。 While running the HQL query it gives the following error: 运行HQL查询时,会出现以下错误:

org.hibernate.QueryException: could not resolve property: IsValidated of: com.cc.myApp.dal.models.BatchFileRecord org.hibernate.QueryException:无法解析属性:IsValidated: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);

It works well using mysql directly but it doesnt works using hibernate, How can i help myself runnimg this? 它可以直接使用mysql很好地工作,但是不能使用hibernate来工作,我该如何帮助自己运行呢? or is there any alternative way to do so? 还是有其他替代方法?

IsValidated with first characted in uppercase doesnt match the java bean standard. IsValidated的第一个大写字母与Java Bean标准不匹配。 Please change the property name or change the getter to getIsvalidated() 请更改属性名称或将getter更改为getIsvalidated()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM