Hibernate session问题~
启动tomcat 加载web.xml。 servlet调用 dao中的isHasSysUser()
为什么总输出:
System.out.println("=====第二步:用户不存在");
并没有去执行select,表里有数据的。。
是不是session的问题?
public boolean isHasSysUser()throws NoSuchUserException{ Session session = null; //HttpSession session=ServletActionContext.getRequest().getSession(); try{ session = Hibernate_Utils.getSession(); session.createSQLQuery("select t.id from T_MENU t where t.id=1").executeUpdate(); System.out.println("=====第二步:用户已经存在"); return true; }catch(Exception e){ System.out.println("=====第二步:用户不存在"); throw new NoSuchUserException(); }finally{ session.close(); } }