public List queryByLike(String cond) throws Exception {
// 模糊查询
String hql = "from Person where name like ?";
Query query = this.session.createQuery(hql);
query.setString(0,"%"+cond+"%");
List list = query.list();
return list;
}
当没有查询到数据时返回的list不为空而是[],谁能告诉我是为什么?
// 模糊查询
String hql = "from Person where name like ?";
Query query = this.session.createQuery(hql);
query.setString(0,"%"+cond+"%");
List list = query.list();
return list;
}
当没有查询到数据时返回的list不为空而是[],谁能告诉我是为什么?
不太明白,还是帮你顶一下
list是一个列表集合,所以不能判断为空,只能判断它的size(长度)为0。