-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Optimize data fetch.
PostPosted: Thu Nov 24, 2005 3:01 am 
Newbie

Joined: Thu Nov 24, 2005 1:23 am
Posts: 1
Hi All,
I have a scenario in which I want to fetch all the Student data into a Student class.
The structure ot Student class is as follows

Student
RollNo
Name
SubjectId
Subject


My table Structure is
Student
RollNo[PK]
Name
SubjectId[FK- Refers Subject.]

Subject
SubjectId[PK]
Subject


I tried to use join
<class name="Student" table="Student">
<id name="RollNo">
<generator class="assigned">
</id>
<property name="Name">
<property name="SubjectId">
<join table="Subject">
<key property-ref="SubjectId"/>
<property name="Subject">
</join>
</class>
What it does is it tries to match SubjectId with the RollNo
ie. Student.RollNo=Subject.SubjectId.

But I want it to match the SubjectId
ie.Student.StudentId=Subject.SubjectId

I am using <many-to-one> relationship now.
But what it does is its firing many queries which I dont want. It first finds out all the StudentIds then it fires the same no of queries as there are students and searches for Subjects for each student. I want to avoid this.

But in simple JDBC I can get all the data using a single join statement.
Is there any method by which I can optimize the data fetch or is there any method where I can join the two tables?

Please help me
Regards
Manjit.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 24, 2005 3:05 am 
Beginner
Beginner

Joined: Tue Nov 22, 2005 4:53 pm
Posts: 41
Location: Netherlands
you will need the <one-to-one> from Student to Subject :)

http://www.hibernate.org/hib_docs/v3/re ... n-onetoone


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.