Query query=session.createQuery("from UserPojo where id=?"); //id为主键
List list=query.list();
int a=list.size();我想知道数据库的一个表中一共有多少行数据,那么按上面的代码查询对不对?最后的那个a为行数 请高手赐教
List list=query.list();
int a=list.size();我想知道数据库的一个表中一共有多少行数据,那么按上面的代码查询对不对?最后的那个a为行数 请高手赐教
SQLQuery q = session.createSQLQuery(sql);
q.addScalar("CNT", Hibernate.INTEGER);
Integer count = (Integer) q.uniqueResult();
return count.intValue();方法接收的返回值为int型