Ok thank's,
but i think, if you can look this bit code, will be useful can use
" .add(Projections.sum("vo.qtavdi*vo.pvendi").as("pvendi"))",
and i will confirm you that hibernate trhows this exception.
Ok i hope to use Projections.sum.
Devis
Code:
org.hibernate.QueryException: could not resolve property: qtavdi*vo.pvendi of: vo.as400.CVenditaVO
at org.hibernate.persister.entity.AbstractPropertyMapping.throwPropertyException(AbstractPropertyMapping.java:43)
at org.hibernate.persister.entity.AbstractPropertyMapping.toType(AbstractPropertyMapping.java:37)
at org.hibernate.persister.entity.BasicEntityPersister.toType(BasicEntityPersister.java:1094)
at org.hibernate.loader.criteria.CriteriaQueryTranslator.getType(CriteriaQueryTranslator.java:442)
at org.hibernate.criterion.AggregateProjection.getTypes(AggregateProjection.java:28)
at org.hibernate.criterion.AliasedProjection.getTypes(AliasedProjection.java:37)
at org.hibernate.criterion.ProjectionList.getTypes(ProjectionList.java:38)
at org.hibernate.loader.criteria.CriteriaQueryTranslator.getProjectedTypes(CriteriaQueryTranslator.java:297)
at org.hibernate.loader.criteria.CriteriaLoader.<init>(CriteriaLoader.java:79)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1297)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:299)
at org.hibernate.impl.CriteriaImpl$Subcriteria.list(CriteriaImpl.java:141)
Code:
Session session = AS400Session.currentSession();
Criteria crit = session.createCriteria(CVenditaVO.class, "vo")
.add(Restrictions.eq("pk.shopdi", shop))
.add(Restrictions.eq("pk.datadi", java.sql.Date.valueOf(data)))
.createCriteria("modevo")
.createCriteria("cmpfmo", "cmp")
.add(Restrictions.eq("cmp.cdc_cmpf", cdc_cat))
.setProjection(Projections.projectionList()
.add(Projections.groupProperty("vo.modedi").as(
"modedi"))
.add(Projections.sum("vo.qtavdi").as("qtavdi"))
.add(Projections.sum("vo.qtavdi*vo.pvendi").as("pvendi"))
)
.setCacheable(true)
.addOrder(Order.desc("qtavdi"))
.setResultTransformer(new AliasToBeanResultTransformer(CVenditaVO.class));