Hello Frnds,
Im developing one web based program using hibernate . But My problem is when the session is lost , and when I tries to relogin ... the starnge error hits
Hibernate: select users0_.Id as Id0_, users0_.Active as Active0_, users0_.Username as Username0_, users0_.Password as Password0_, users0_.Firstname as Firstname0_, users0_.Lastname as Lastname0_, users0_.Email as Email0_, users0_.Projects_permission as Projects8_0_, users0_.Properties_permission as Properties9_0_, users0_.Clients_permission as Clients10_0_, users0_.Users_permission as Users11_0_, users0_.Resellers_permission as Resellers12_0_, users0_.Accounting_permission as Accounting13_0_ from users users0_ where Username='shabeel' and Password='shabeel' Error2 : could not execute query
Please verify the program
public class AdminLoginPageAction extends Action { public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception{ AdminLoginPageActionForm formObj = (AdminLoginPageActionForm)form; /*Get the servlet context */ ServletContext context = request.getSession().getServletContext(); /*Retrieve Session Factory */ SessionFactory _factory = (SessionFactory) context.getAttribute(HibernatePlugIn.SESSION_FACTORY_KEY); /*Open Hibernate Session */ Session session = _factory.openSession(); //Criteria Query Example try { List result=session.createQuery("from Users where Username='"+formObj.getUsername()+"' and Password='"+formObj.getPassword()+"'").list(); int count=result.size();
HttpSession mysession = request.getSession(); if(mysession.getAttribute("admin_login_status")!=null) { if(mysession.getAttribute("admin_login_status").equals("true")) { session.close(); return mapping.findForward("success"); } } if(count>0) { Iterator itr = session.createQuery("from Users where Username='"+formObj.getUsername()+"'").list().iterator(); Users user= (Users) itr.next(); mysession.setAttribute("admin_login_status","true"); mysession.setAttribute("adminloginusername", user.getFirstname()+" "+user.getLastname()); session.close(); return mapping.findForward("success"); } else { mysession.setAttribute("admin_login_status","false"); mysession.setAttribute("error","invalid"); session.close(); return mapping.findForward("failure"); } } catch (Exception e) { System.out.println("Error2 : "+e.getMessage()); session.close(); return mapping.findForward("failure"); }
why this strange error hits? when I restart the server it becomes normal ...
Please help
Regards
/*Close session */
}
}
|