If no expressions in the select are supported, how then can I sum the product of two properties?
The following works:
Code:
select new employeeclub.report.TicketSaleSummaryDto(activity.id, activity.name, activityTicket.quantity, sum(lineItem.quantity), activityTicket.unitCost, sum([b]lineItem.unitCost[/b]))
from
Activity activity,
ActivityTicket activityTicket,
LineItem lineItem
where activityTicket.id = lineItem.item.id group by activity.id, activity.name, activityTicket.quantity, activityTicket.unitCost
but the following does not:
Code:
select new employeeclub.report.TicketSaleSummaryDto(activity.id, activity.name, activityTicket.quantity, sum(lineItem.quantity), activityTicket.unitCost, sum([b]lineItem.unitCost * lineItem.quantity[/b]))
from
Activity activity,
ActivityTicket activityTicket,
LineItem lineItem
where activityTicket.id = lineItem.item.id group by activity.id, activity.name, activityTicket.quantity, activityTicket.unitCost
Here, lineItem.unitCost is of type Money, lineItem.quantity is of type int.
I receive the following error:
Code:
org.springframework.orm.hibernate.HibernateSystemException: no appropriate constructor in class: employeeclub.report.TicketSaleSummaryDto; nested exception is net.sf.hibernate.PropertyNotFoundException: no appropriate constructor in class: employeeclub.report.TicketSaleSummaryDto
net.sf.hibernate.PropertyNotFoundException: no appropriate constructor in class: employeeclub.report.TicketSaleSummaryDto
I have no idea what sum(lineItem.unitCost * lineItem.quantity) would be returned as. How can you tell? It would be nice if Hibernate provided the method signature it was looking for. I have tried Integer, int, Long, long, Double, double, BigDecimal, Object and Money. No dice. How can I tell what Hiberate resolves this as?
Regards,
Joshua