Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hql And sql Queries

 
Kiran Kumar Adhi
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 547
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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/
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic