aspose file tools*
The moose likes Object Relational Mapping and the fly likes Multiple Object Select Problems Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Multiple Object Select Problems" Watch "Multiple Object Select Problems" New topic
Author

Multiple Object Select Problems

Navin Keswani
Greenhorn

Joined: Jun 08, 2004
Posts: 17
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Multiple Object Select Problems