08-07
16
Hibernate中的query只一个数值count
作者:Java伴侣 日期:2008-07-16
复制内容到剪贴板 程序代码
String sql ="Select COUNT(*) FROM PRODUCTS as p Where p.g_id="+ cate.getId() +"";
Query query = session.createSQLQuery(sql, "p", Product.class);
Query query = session.createSQLQuery(sql);
Object[] ob=query.list().toArray();
int num = =Integer.parseInt(ob[0].toString());
Query query = session.createSQLQuery(sql, "p", Product.class);
Query query = session.createSQLQuery(sql);
Object[] ob=query.list().toArray();
int num = =Integer.parseInt(ob[0].toString());
评论: 0 | 引用: 0 | 查看次数: 642
发表评论