xjodoin/torpedoquery — Issue #13: CoalesceFunction cannot be cast to java.math.BigDecimal
Author: cnadeau
Created: 2012-01-10 14:13:40+00:00
State: open

OrderDetailToShip orderDetailToShipQuery = from(OrderDetailToShip.class);
ShippingDetail shippingDetailQuery = leftJoin(orderDetailToShipQuery.getShippings());
OrderDetail orderDetailQuery = rightJoin(orderDetailToShipQuery.getOrderDetail());
SaleTransaction orderQuery = innerJoin(orderDetailQuery.getSaleTransaction());

where(orderDetailQuery.getProduct()).eq(product).and(orderQuery.getCompany()).eq(company);

groupBy(orderDetailQuery.getId(), orderDetailQuery.getQuantityConvertedValue(), shippingDetailQuery.getQuantityConvertedValue()).having(
orderDetailQuery.getQuantityConvertedValue()).gt(coalesce(sum(shippingDetailQuery.getQuantityConvertedValue()), constant(BigDecimal.ZERO)));

Query select = select(sum(orderDetailQuery.getQuantityConvertedValue()));

List sumByDetail = select.list(manager);