新手,刚刚学习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)