IntelliJ Java IDE
The moose likes Object Relational Mapping and the fly likes HIBERNATE:  Problem with ASSOCIATION combined with AGGREGATION Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Object Relational Mapping
Reply Bookmark "HIBERNATE:  Problem with ASSOCIATION combined with AGGREGATION" Watch "HIBERNATE:  Problem with ASSOCIATION combined with AGGREGATION" New topic
Author

HIBERNATE: Problem with ASSOCIATION combined with AGGREGATION

O. Thoms
Greenhorn

Joined: Nov 21, 2006
Posts: 10
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

Joined: Feb 05, 2001
Posts: 16622

"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.


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
 
subject: HIBERNATE: Problem with ASSOCIATION combined with AGGREGATION
 
Threads others viewed
Select box overlaps the layer issue in IE
criteria format in criteriaFind method
Adding nested loop in order to print out a table
How to select a particular checkbox in a series
hibernate either / or query?
MyEclipse, The Clear Choice

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture