String hql = "select new com.ac.erp.model.CreditCustomer( customerId ,customerName ,creditconsignment , uninvoice ,creditinvoice , creditmoney ) from ("
    
+ " select a.customerId as customerId , a.customerName as customerName , " 
    
+" isnull(b.consignments,0) as creditconsignment "
    
+" isnull(b.consignments,0) - isnull(c.invoices,0) +  isnull(f.price,0) as uninvoice , "+" isnull(c.invoices,0) - isnull(e.payments,0) + isnull(d.invoiceadvance,0)  as creditinvoice , "+" isnull(b.consignments,0) + isnull( f.price , 0) - isnull(e.payments,0) + isnull(d.invoiceadvances , 0 )  as creditmoney  "+" from Customer a "+" left join "+" ( select consignment.customerId as customerId , sum(consignmentproductMoney) as consignments from Consignmentproduct group by consignment.customerId ) b on a.customerId = b.customerId "
+" left join "+" ( select invoice.customerId as customerId , sum(invoiceproductMoney) as invoices from Invoiceproduct group by invoice.customerId) c on c.customerId = a.customerId "+" left join "+" (select invoiceadvance.customerId as customerId , sum(invoiceadvanceproductMoney) as invoiceadvances from Invoiceadvanceproduct group by invoiceadvance.customerId ) d on d.customerId = a.customerId "+" left join "+" (select customerId as customerId , sum(paymentMoney) as payments from Payment group by customerId ) e on e.customerId = a.customerId "+" left join "+" (select invoice.customerId as customerId , sum(invoiceproductmoney - invoiceproductNum * ( consignmentproduct.consignmentproductPrice * productunit.productunitRe / consignmentproduct.productunit.productunitRe ) ) as price  from Invoiceproduct ) as f on f.customerId = a.customerId   ) as z";hql子查询 级联