hql果然不支持啊……但我用sql语句,直接用createSQL也是可以的,但不知道为什么list里面的数据取不出来,总是说类型不匹配……
Session getSession(){..............} List getTopOne() { Session s = getSession(); Query q = s.createSqlName(\"select top 1 * from room\"); return q.list();}void showTopOne() { List l = getTopOne(); Room r = (Room) l.get(0); //报错}
List getTopOne() { Session s = getSession();
Query q = s.createSqlName(\"select top 1 * from room\");
return q.list();}void showTopOne() { List l = getTopOne(); Room r = (Room) l.get(0); //报错}