[英]Hibernate Criteria Query Issue with Projection and restriction
I am trying to get selected columns from a table using hibernate criteria query 我试图使用hibernate条件查询从表中选择列
Criteria cr = session.createCriteria(OfferCashbackMaster.class)
.setProjection(Projections.projectionList()
.add(Projections.property("txnType"), "txnType")
.add(Projections.property("off_Discription"), "off_Discription"))
.setResultTransformer(Transformers.aliasToBean(OfferCashbackMaster.class))
.add(Restrictions.and(Restrictions.eq("aggregatorId", aggregatorId),
Restrictions.eq("txnType", txnType)));
The name txnType
mentioned in projection is having a clash with restriction. 投影中提到的名称
txnType
与限制发生冲突。
Giving me the following error 给我以下错误
Hibernate:
select
this_.OFFER_CODE as y0_,
this_.TXN_TYPE as y1_,
this_.VALID_TO as y2_,
this_.OFFER_DISCRIPTION as y3_
from OFFER_CASHBACK_MASTER this_
where
(this_.AGGREGATOR_ID=? and y1_=?)
2018-02-25/15:42:41.756 WARN: util.JDBCExceptionReporter -
SQL Error: 1054, SQLState: 42S22
2018-02-25/15:42:41.757 ERROR: util.JDBCExceptionReporter -
Unknown column 'y1_' in 'where clause'
How can we solve this issue? 我们如何解决这个问题?
I believe you're using the outdated version of hibernate. 我相信你正在使用过时的hibernate版本。
The issue is addressed and resolved for a long time: 这个问题已经解决并解决了很长时间:
https://hibernate.atlassian.net/browse/HHH-817 https://hibernate.atlassian.net/browse/HHH-817
Fixed version: 3.6.0.Beta4
修正版:
3.6.0.Beta4
If you are using Hibernate 3.2.6, 3.0.5, 3.5.5, 3.6.0.Beta3
then it's time for migrating to newer version of Hibernate. 如果你使用的是Hibernate
3.2.6, 3.0.5, 3.5.5, 3.6.0.Beta3
那么现在是时候迁移到更新版本的Hibernate了。
Reported bug: Criteria Query Issue with Projection and restriction 报告的错误: 标准查询问题与投影和限制
Link: https://hibernate.atlassian.net/browse/HHH-3371 链接: https : //hibernate.atlassian.net/browse/HHH-3371
Affects Version/s: 3.2.6 3.0.5, 3.5.5, 3.6.0.Beta3
影响版本:
3.2.6 3.0.5, 3.5.5, 3.6.0.Beta3
Component/s: query-criteria 组件:查询标准
Fix Version: 3.6.0.Beta4 and above. 修复版本:3.6.0.Beta4及以上版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.