tags:

views:

209

answers:

1

Hi,

I am new to Hibernate. I need to perform select item.itemName, (item.Qty * item.Price) as total Price from Item item' in Hibernate criteria query. i tried,

objCriteria = objSession.createCriteria(ItemVO.class, "IT")
.setProjection(Projections.projectionList()
.add(Projections.property("IT.name"), "itemName")
.add(Projections.sqlProjection("(QTY * cost)", new Float[] {"TotalCost"}, ( new Type[] {Hibernate.Float}))))
.setResultTransformer(Transformers.aliasToBean(ConsumableDTO.class));

But I need with HQL name instead of direct sql query column name. how to achieve it?