HIBERNATE: Problem with ASSOCIATION combined with AGGREGATION
O. Thoms
Greenhorn
Joined: Nov 21, 2006
Posts: 10
posted
0
I have a probliem quite like this:
A Ship stores containers, a container holds boxes, boxes have a weight.
I now want to load those ship objects that have a total weight less than 100 tons.
In SQL it would be something like:
SELECT ship.ship_id FROM ship, container, box WHERE ship.ship_id = (+)conatiner.ship_id AND container.container_id = (+)box.container_id GROUP BY ship.ship_id HAVING SUM(box.weight) < 100
I tried several approaches but either I end up with the correct ships selected but only their id's, ie a List containing Integers (Root Object for Criteria was box.class). Or the call crashes cause it tries to select the weight directly from the ship object (Root Object for Criteria was ship.class)
I can't get it running, neither with HQL nor the Criteria API.