首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

Hibernate 错误

2012-01-01 
Hibernate 异常为什么下面的程序会抛出异常:public ActionForward execute(ActionMapping mapping, Action

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;
}
}

[解决办法]
吧你的错误信息放上来

热点排行