• 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");



 
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!