I'm currently using Hibernate Criteria to create a summary query with SUM, When there are no values for that SUM I'd like to receive 0 instead of null,
Here's my pojo's code
Code:
public class DetalleLibroMayor {
private Cuenta cuenta;
private BigDecimal debe = BigDecimal.ZERO;
private BigDecimal haber = BigDecimal.ZERO;
And this is the query (just the projection part)
Code:
ProjectionList projection = Projections.projectionList();
projection.add(Projections.property("cuenta").as("cuenta"));
projection.add(Projections.sum("debe").as("debe"));
projection.add(Projections.sum("haber").as("haber"));
projection.add(Projections.groupProperty("cuenta.id"));
criteria.setProjection(projection);
criteria.setResultTransformer(Transformers.aliasToBean(DetalleLibroMayor.class));
Any idea? Thanks