if(pList.size()>0)
{
p=(List<TblRentInfo>) pList.get(0);
//System.out.println(p.add(pList.get(0)));
System.out.println("2222222");
System.out.println(p);
}
return p;

}


public  List<TblRentInfo> search(String condition) throws Exception
{
  List<TblRentInfo> userList=new ArrayList<TblRentInfo>();
  try
{
session=HibernateSessionFactory.getSession();
Query query=session.createQuery("from TblRentInfo where 1=1 "+condition);
userList=query.list();
System.out.println("1111111111");
}catch(Exception ex)
{
ex.printStackTrace();
throw new Exception("数据库错误");
}finally
{
HibernateSessionFactory.closeSession();
}
 
  return userList;
}

Hibernate Struts
分享到:

------解决方案--------------------
p=(List<TblRentInfo>) pList.get(0);
p应该不是list 而是TblRentInfo
改为p=(TblRentInfo) pList.get(0);
------解决方案--------------------
userList=query.list();这一句不需要强转吗
------解决方案--------------------
List<TblRentInfo> pList=userDao.search("and title='"+title+"'");
pList 这个有值吗?这个有值的话,直接 return pList.get(0);
查看全文
  相关解决方案