• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How To Value Outside While loop iterator in hibernate

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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]
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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");



reply
    Bookmark Topic Watch Topic
  • New Topic