读书人

Hibernate session有关问题

发布时间: 2012-02-27 10:00:22 作者: rapoo

Hibernate session问题~
启动tomcat 加载web.xml。 servlet调用 dao中的isHasSysUser()
为什么总输出:
System.out.println("=====第二步:用户不存在");

并没有去执行select,表里有数据的。。
是不是session的问题?


Java code
    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();        }    }



[解决办法]
把异常打出来就知道了啊 你都抛走了,,,
[解决办法]
session.createSQLQuery("select t.id from T_MENU t where t.id=1");

读书人网 >Java Web开发

热点推荐