[求助]Hibernate用distinct关键字,返回的对象类型不正确的问题
String hql = "select distinct user.loginName,user.nickName,user.password from User user";Query query = sess.createQuery(hql);
List list = query.list();
Hibenate生成 Hibernate: select distinct user0_.login_name as col_0_0_, user0_.nick_name as col_1_0_, user0_.password as col_2_0_ from school.user user0_
我想要得到返回的list中的内容怎么得到呢?
for (Iterator iter = list.iterator(); iter.hasNext();)
{
User user = (User)iter.next(); // 这样报错ClassCastException
System.out.println(user.getLoginName()+" " + user.getNickName());
}
请高手帮忙指点我一下,谢谢!