首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2EE开发 >

hibernate 查询出的list不能转换成持久化类解决思路

2012-04-18 
hibernate 查询出的list不能转换成持久化类新手,刚刚学习ssh2框架,登陆功能,这是我写在Dao类下的方法:publ

hibernate 查询出的list不能转换成持久化类
新手,刚刚学习ssh2框架,登陆功能,这是我写在Dao类下的方法:
public UserClient findClient(String userName,String password){
String[] param =new String []{userName,password};
String sql="form UserClient as model where model.userName = ? and model.password = ? ";
List<UserClient> list=(List<UserClient>)getHibernateTemplate().find(sql,param);
if(list != null && list.size()>0)
{
return (UserClient)list[0]; //这里报错!!! 
}
else
return null;
}
但是list[0]这里报错,
说The type of the expression must be an array type but it resolved to List<UserClient>
UserClient是持久化类,我用Myeclipse的hibernate reverse engineering 自动生成的

[解决办法]
list.get(0)

热点排行