-->
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.  [ 6 posts ] 
Author Message
 Post subject: Having probem in fetchin Object
PostPosted: Fri Dec 22, 2006 10:53 am 
Newbie

Joined: Fri Dec 22, 2006 10:45 am
Posts: 5
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

I am using hibernate 3.0

Following is my mapping file


[code]hibernate-mapping package="course.model">

<class name="Course" table="COURSE">
<id name="courseId"
column="COURSE_ID">
<generator class="assigned"/>
</id>

<property name="tinNbr"
column="TIN"
type="string"
update="false"
not-null="true"/>

<property name="pin"
type="string"
column="PIN"
update="false"/>


<property name="courseName"
type="string"
column="COURSE_NAME"
update="false"/>

<property name="courseType"
type="string"
column="COURSE_TYPE"
update="false"/>

<property name="courseAssin"
type="string"
column="CURSE_ASSIGN"
update="false"/>


</class>

</hibernate-mapping>[/code]

Following is my code I am trying to execute

[code]List courses = getHibernateTemplate().find("from Course e where e.tinNbr = ? and e.pinNumber = ?",
new Object[]{tin,pin});



for (Iterator it = courses.iterator(); it.hasNext(); ) {
Course cdrins = (Course)it.next();
String courseName = cdrins.getCourseName();
System.out.println("Course name is " + courseName);
}[/code]



My problem is .I am expected to get the different rows with different values of Course object.But when I displays
the result I am getting the first row three times.

System.out should display like

Expected :

Course name is English
Course name is Physics
Course name is Chemestry


But is displays like:

Course name is English
Course name is English
Course name is English



I will appreciate if somebody helps me out.I am been puzzling in this for a while.

Thanks,


Last edited by sam73 on Fri Dec 22, 2006 11:32 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Having probem in fetchin Object
PostPosted: Fri Dec 22, 2006 11:18 am 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
for (Iterator it = courses.iterator(); it.hasNext(); ) {
Course cdrins = (Course)it.next();
String courseName = cdrins.getCourseName();
System.out.println("Course name is " + course);
}



I bolded the problem

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 22, 2006 11:31 am 
Newbie

Joined: Fri Dec 22, 2006 10:45 am
Posts: 5
Sorry about that.It is courseName insteed of course in System.out
statement.Still the problem is there.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 22, 2006 11:48 am 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
check the logs. see what's being returned

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 26, 2006 1:56 pm 
Newbie

Joined: Fri Dec 22, 2006 10:45 am
Posts: 5
Logs Also shows the first object returns 3 times insteed of three different object.

I will appreciate any help.Juggling with this for a while.

Thanks.


Top
 Profile  
 
 Post subject: Re: Having probem in fetchin Object
PostPosted: Tue Dec 26, 2006 10:53 pm 
Newbie

Joined: Tue Dec 26, 2006 10:46 pm
Posts: 1
Location: Dallas, USA
Basically you need to find out why the same ID is being fetched from the database repeatedly.

One reason could be if only the first character of your ID Column is being fetched from the Database. For eg: '3' instead of '33', '34', '35'. Print out the ID and see what it gets from the DB everytime it fetches a row. You can also test this by setting the ID interval to 10, create the language records in the DB again and then see if it still fetches them repeatedly.

_________________
regards,
Tariq


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.