I am trying to get selected columns from a table using hibernate criteria query
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.
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?