• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HIBERNATE: Problem with ASSOCIATION combined with AGGREGATION

 
O. Thoms
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.


Plase, any Help welcome....
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Oliver T",
Welcome to the JavaRanch.

We're a friendly group, but we do require members to have valid display names.

Display names must be two words: your first name, a space, then your last name. Fictitious names are not allowed.

Please edit your profile and correct your display name since accounts with display names get deleted.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic