This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How To Value Outside While loop iterator in hibernate

 
RajeshKumar Nayak
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Query hql=sc.createQuery("from com.rajesh.Student");
ArrayList plist=(ArrayList)hql.list();
Iterator it=plist.iterator();

while(it.hasNext()){
Student std=(Student)it.next();
}
String stdid=std.getStdid(); //error:-std cannot be resolved

if(stdId.equalsIgnoreCase("std.id")&& stdPwd.equalsIgnoreCase("nayak"))
return mapping.findForward("Sus");
---------------------------------------------------------------------------
In above Code I want to use "std" outside of while loop for getting some value and check with "stdId" and "std.stdid"
and I want return some value outside while lop.
How it possible someone Explain me How it possible[color=red]
 
surendra babu k
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

std contains multiple students then write your test case in while loop only..because you need to test it for every student object.
 
RajeshKumar Nayak
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually i am using Struts So
We cannot write all the test case inside the
while loop i want the value for stdid outside the loop
 
surendra babu k
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Query hql=sc.createQuery("from com.rajesh.Student");
ArrayList plist=(ArrayList)hql.list();
Iterator it=plist.iterator();

boolean validstd=false;

while(it.hasNext()){
Student std=(Student)it.next();
String stdid=std.getStdid();
if(stdId !=null && stdId.equalsIgnoreCase("std.id")&& stdPwd.equalsIgnoreCase("nayak"))
{
validstd=true;
break;
}
}
if(validstd)
return mapping.findForward("Sus");



 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic