posted 17 years ago
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