一路拾遗
Collect By Finding All The Way ......
posts - 81,comments - 41,trackbacks - 0
 
    public int getCount(String emailGroupId, String emailBatchId)
            
throws HibernateException {

        Session session 
= HibernateUtil.currentSession();
        Transaction tx 
= session.beginTransaction();

        String hql 
= "select count(*) from EmailSendInfo where email_group_id = :emailGroupId and batch_id = :batchId";
        Query query 
= session.createQuery(hql);

        query.setString(
"emailGroupId", emailGroupId);
        query.setString(
"batchId", emailBatchId);
        
/*
         * for (Iterator it = query.iterate(); it.hasNext();) { return
         * ((Integer) it.next()).intValue(); }
         
*/

        
try {
            
return ((Integer) query.iterate().next()).intValue();
        }
 catch (Exception e) {
            
throw new HibernateException("");
        }
 finally {
            tx.commit();
            HibernateUtil.closeSession();
        }

    }
posted on 2009-07-13 10:46 胖胖泡泡 阅读(319) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航: