File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes Hql And sql Queries Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Object Relational Mapping
Reply Bookmark "Hql And sql Queries" Watch "Hql And sql Queries" New topic
Author

Hql And sql Queries

Kiran Kumar Adhi
Greenhorn

Joined: Jul 02, 2006
Posts: 3
I have a Trip and Leg tables. They are related as : One Trip can have 1 or more Legs. And Leg has fields: DepartTime, ArrivalTime, From, To.

I want to Fetch All Trips, and with in each Trip I require only the First Leg (Leg with LeastDeparttime).

How could I write a HQL query for this ?
My Trip Class contains a Set (Collection) of Legs.
pascal betz
Ranch Hand

Joined: Jun 19, 2001
Posts: 547
some thoughts:
- get the leg and the associated trip instead of the trip and just one leg ?
- use a collection filter ?
http://lizjason.com/blog/2005/11/08/seven-tips-for-hibernate-collection-filters/
 
 
subject: Hql And sql Queries
 
Threads others viewed
Trip, legs, use cases (Part II)
Are Leg and Segment synonyms?
Flight & Segment
Route - Flight - Segment again.
construct 2 dimensional array
IntelliJ Java IDE