当前位置: 代码迷 >> Java Web开发 >> Hibernate 错误
  详细解决方案

Hibernate 错误

热度:636   发布时间:2016-04-17 12:35:27.0
Hibernate 异常
为什么下面的程序会抛出异常:
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
LoginForm LoginForm = (LoginForm) form;
ActionMessages errors=new ActionMessages();
ActionForward forward=mapping.findForward("frontPage");
try{
Session dbSession=HibernateSessionFactory.getCurrentSession();
HttpSession session=request.getSession();
String hqlStr="from Userinfo as u where u.username=:username and u.pwd=:pwd";
Query query=dbSession.createQuery(hqlStr);
query.setString("username",LoginForm.getUsername());
query.setString("pwd",LoginForm.getPassword());

List result=query.list();
if(result.size()==0){
errors.add("inputErrors",new ActionMessage("index.loginError"));
this.saveMessages(request,errors);
forward=mapping.findForward("failed");
}else{
Userinfo user=(Userinfo) result.get(0);
session.setAttribute("user",user);
if(user.getPower()==1){
session.setAttribute("admin",true);
}
}
}catch(Exception e){
errors.add("dbError",new ActionMessage("globle.dbError"));
this.saveMessages(request,errors);
forward=mapping.findForward("errorPage");
}
return forward;
}
}

------解决方案--------------------
吧你的错误信息放上来
  相关解决方案