Think I found the answer. You must use the Projection.sqlProjection() and not Projections.sum(). Example:
.setProjection(Projections.sqlProjection("sum(cast(amount as signed)* direction) as amntDir", new String[] {"amntDir"} , new Type[] {Hibernate.DOUBLE}));
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…