本文共 2275 字,大约阅读时间需要 7 分钟。
当前位置:我的异常网» Java Web开发 » 新手使用find()有关问题求助
新手使用find()有关问题求助
www.myexceptions.net 网友分享于:2013-12-05 浏览:433次
新手使用find()问题求助。
我的代码:
import java.util.List;
import org.acegisecurity.providers.encoding.Md5PasswordEncoder;
import org.acegisecurity.providers.encoding.PasswordEncoder;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springside.core.dao.HibernateEntityDao;
import com.my.security.model.User;
public class CustomerUser extends HibernateEntityDao {
final Log buzzLog = LogFactory.getLog(Constants.BUSINESS_LOG);
public int UserCheck(String userid, String passwd){
buzzLog.info( "--- Check Begin --- ");
int ret = 1;
String hql;
String passwd2;
PasswordEncoder passwordEncoder = new Md5PasswordEncoder();
passwd2 = passwordEncoder.encodePassword(passwd, null);
hql = "from user u where number=? and passwd=? ";
try {
buzzLog.info( "---find begin ---\n " + hql);
List userList = find(hql,userid,passwd2);
if ( userList.size() > 0) {
ret = 0;
}
}
catch(Exception e){
buzzLog.info( "---find error --- ");
e.printStackTrace();
ret = -1;
}
return ret;
}
public List find(String hql, Object... values) {
Assert.hasText(hql);
return getHibernateTemplate().find(hql, values);
}
}
执行时报错:
2007-07-09 13:05:26,375 INFO [business] -
2007-07-09 13:05:26,421 INFO [business] -
from ss_users u where number=? and passwd=?>
2007-07-09 13:05:26,421 INFO [business] -
java.lang.NullPointerException
at org.springside.core.dao.HibernateGenericDao.find(HibernateGenericDao.java:159)
at com.my.commons.CustomerUser.UserCheck(CustomerUser.java:34)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:270)
at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:187)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
文章评论
转载地址:http://fhudv.baihongyu.com/