• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Multiple Object Select Problems

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,


I have School and Student table .
There is a one to many relationship. One school can have many students
Now when I wite a SQL query to the School table to get the complete school info.

Now this query returns me a school which has a student which is the eldest age wise in the entire studdnt table.

so when I run the sql it would give me 1 School record.

In that record I want to display student name also

Now when I execute the same in Hibernate it works just fine it gives me just one School object which is what I want but when I need to retrieve the student information from there which has One to many mapping means School would have getStudents() which returns a list of students when I do that it doesnt return me just the student which has the max age but it returns all the students which belong to that school.

so If the school has 3 rows with school id 1 2 3 and student has 150 rows with 50 students belonging to school 1 and other 50 belonging to school 2 and the rest 50 to school 3 so school_1 getStudents will return me 50 students and not just the studnet which has the max age as was specified in the criteria although it returns me the correct and only 1 school object but not the case with the linked classes

can you please provide me some insight on the same

I am currently using Criteria objects for querying

Some one suggested using Hibernate Report queries

Thanks,
Navin Keswani
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic