Ê×Ò³ Ê«´Ê ×Öµä °å±¨ ¾ä×Ó ÃûÑÔ ÓÑ´ð ÀøÖ¾ ѧУ ÍøÕ¾µØͼ
µ±Ç°Î»ÖÃ: Ê×Ò³ > ½Ì³ÌƵµÀ > JAVA > Java Web¿ª·¢ >

ΪʲôһִÐоͻᱨ´íÄؽâ¾ö°ì·¨

2012-03-25 
ΪʲôһִÐоͻᱨ´íÄØÖ´ÐÐÕâ¸ö¶¼»áÓÐ´í£¬publicbooleanhasUser(JspUserinfouser){booleanflagfalseQuer

ΪʲôһִÐоͻᱨ´íÄØ
Ö´ÐÐÕâ¸ö¶¼»áÓÐ´í£¬
        public   boolean   hasUser(JspUserinfo   user)
        {
                boolean   flag   =   false;
                Query   query   =   session.createQuery( "from   JspUserinfo   ");
                if   (query.list().size()   !=   0)
                {
                        flag   =   true;
                }
                return   flag;
        }
ÊÇʲôÎÊÌâ?
´íÎóÐÅÏ¢.
java.lang.NullPointerException
at   com.cc.hibernate.ActionJspUserinfo.hasUser(ActionJspUserinfo.java:200)
at   com.logon.app.LogonAction.execute(LogonAction.java:46)



[½â¾ö°ì·¨]
Ó¦¸ÃÊÇquery.list()·µ»ØµÄListÊÇNULL
Äã²é¿´Ò»ÏÂ
[½â¾ö°ì·¨]
Ò²¿ÉÄÜÊÇsessionûÓлñµÃ¡£
[½â¾ö°ì·¨]
//Õâ¾ä if (query.list().size() != 0)

¿ÉÒÔÏȲð·Öµ÷ÊÔÏ ¿´queryÊÇnull »¹ÊÇquery.list()ÊÇnull
[½â¾ö°ì·¨]
»Ø¸´ÈË£ºrjzou2006(Ò»¸öСÅÝ) ( Ò»¼¶(³õ¼¶)) ÐÅÓþ£º100 2007-9-19 9:57:45 µÃ·Ö:0
?

Query query = session.createQuery( "from JspUserinfo ");
ÎÒÊÇÏëÎÊһϣ¬ÔÚÖ´ÐÐÕâ¾äµÄʱºò£¬ÊÇ·ñÒ»¶¨Òª¸øJspUserinfoÖ÷¼ü¸³ÖµÄØ£¿


Ó¦¸ÃÊDz»ÓõÄ
[½â¾ö°ì·¨]
¸Ä³É£º

List list = query.list();
if(list != null) {
if(list.size() > 0) {
flag = true;
}
}
return flag;

ÈȵãÅÅÐÐ