-->
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.  [ 4 posts ] 
Author Message
 Post subject: Problem in One to Many Association
PostPosted: Tue Mar 08, 2005 7:59 am 
Beginner
Beginner

Joined: Thu Feb 24, 2005 8:27 am
Posts: 21
Actually i Have two classes Called ExamineeTest and ExamineeTestQuestion.
ExamineeTest can Contain many ExamineeTestQuestion.

I have specify following thing in ExamineeTest.hbm.xml :

<set name="examineequestions" inverse="true" lazy="true" cascade="delete">
<key column="examineeid"></key>
<one-to-many class="Examineetestquestions"/>
</set>

where examineeid is a field for examineetestquestion. and it is also a field of ExamineeTest and not a primary key.

in ExamineeTestQuestion.hbm.xml is have specify :
<property name="examineeid" column="examineeID" type="java.lang.String" not-null="false"></property>

i have able to successfully load the object. but when i try to retrieve Examineetestquestion throught ExamineeTest method call getExamineequestions it shows error :

well between Session.BeginTrasaction and Session.Close i have written

Query q=ss.createQuery("select e.getExamineequestions from Examineetest e where e.examineeid=\'roshan\'");
Examineetest et= (Examineetest)ss.find("from Examineetest e where e.examineeid=\'Roshan\'").get(0);
System.out.println(et.getExamineeid());
Set s= et.getExamineequestions();
Iterator i= s.iterator();
System.out.println(s.size() );
System.out.println(((Examineetestquestions)i.next()).getQuestionid());


Erro is :


java.util.NoSuchElementException
at java.util.HashMap$HashIterator.nextEntry(HashMap.java:785)
at java.util.HashMap$KeyIterator.next(HashMap.java:818)
at net.sf.hibernate.collection.PersistentCollection$IteratorProxy.next(PersistentCollection.java:437)
at myclient.MyClient.main(MyClient.java:135)



How should i access the question related to examineetest. Is there any way to solve this type of question


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 09, 2005 3:40 am 
Beginner
Beginner

Joined: Thu Feb 24, 2005 8:27 am
Posts: 21
Please Help me Out.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 09, 2005 8:06 am 
Newbie

Joined: Wed Jan 26, 2005 10:17 pm
Posts: 8
call hasNext() on your iterator to see if it had any elements...


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 10, 2005 5:02 am 
Beginner
Beginner

Joined: Thu Feb 24, 2005 8:27 am
Posts: 21
Actually Iterator.size showing me 0 element. But i have 2 records. of ExamineeTestQuestion. Then Why it is showing me 0. can u help me out.


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