此为DAOImpl类 public TbAssignment loadByLoginName(String loginName) { System.out.println(loginName); String hqlString = " from TbAssignment u where u.tbUser.userLoginname='"+loginName+"' "; List list = th... 此为DAOImpl类
public TbAssignment loadByLoginName(String loginName) {
System.out.println(loginName);
String hqlString = " from TbAssignment u where u.tbUser.userLoginname='"+loginName+"' ";
List list = this.getHibernateTemplate().find(hqlString);
if (list != null && list.size() > 0) {
return (TbAssignment) list.get(0);
} else {
return null;
}
}
测试类
@Test
public void t_pwd (){
TbAssignmentDaoImpl tbd = new TbAssignmentDaoImpl();
TbAssignment tb =tbd.loadByLoginName("XXXX");
System.out.println(tb.getTbUser().getUserLoginpwd());
}
tb.getTbUser().getUserLoginpwd()肯定是这句报了异常
然后你看
List list = this.getHibernateTemplate().find(hqlString);
if (list != null && list.size() > 0) {
return (TbAssignment) list.get(0);
} else {
return null;
}
说明方法返回了null
你看看你的hqlString里面的名字数据库能查到么。