@Test public void testGetDownloadSizePerUser () { User u = udao.getByName ("babar"); long expected = 68; long size = dao.getDownloadedSizeByUserSince (u, period); Assert.assertEquals (size, expected); }
public long getDownloadedSizeByUserSince (final User user, final Date date) { Long result = getHibernateTemplate ().execute (new HibernateCallback<Long> () { @Override public Long doInHibernate (Session session) throws HibernateException, SQLException { Criteria criteria = session.createCriteria ( NetworkUsage.class); criteria.setProjection (Projections.sum ("size")); criteria.add (Restrictions.eq ("isDownload", true)); criteria.add (Restrictions.eq ("user", user)); criteria.add (Restrictions.gt ("date", date)); return (Long) criteria.uniqueResult (); } }); return (result == null) ? 0 : result; }
NetworkUsageDao extends HibernateDao<NetworkUsage, Long> { public long getDownloadedSizeByUserSince (final User user, final Date date) { Long result = getHibernateTemplate ().execute (new HibernateCallback<Long> () { @Override public Long doInHibernate (Session session) throws HibernateException, SQLException { Criteria criteria = session.createCriteria ( NetworkUsage.class); criteria.setProjection (Projections.sum ("size")); criteria.add (Restrictions.eq ("isDownload", true)); criteria.add (Restrictions.eq ("user", user)); criteria.add (Restrictions.gt ("date", date)); return (Long) criteria.uniqueResult (); } }); return (result == null) ? 0 : result; } }
NetworkUsageDao extends HibernateDao<NetworkUsage, Long> { public long getDownloadedSizeByUserSince (final User user, final Date date) { Long result = getHibernateTemplate ().execute (new HibernateCallback<Long> () { @Override public Long doInHibernate (Session session) throws HibernateException, SQLException { Criteria criteria = session.createCriteria ( NetworkUsage.class); criteria.setProjection (Projections.sum ("size")); criteria.add (Restrictions.eq ("isDownload", true)); criteria.add (Restrictions.eq ("user", user)); criteria.add (Restrictions.gt ("date", date)); return (Long) criteria.uniqueResult (); } }); return (result == null) ? 0 : result; }  }
NetworkUsageDao extends HibernateDao<NetworkUsage, Long> { public long getDownloadedSizeByUserSince (final User user, final Date date) { Long result = getHibernateTemplate ().execute (new HibernateCallback<Long> () { @Override public Long doInHibernate (Session session) throws HibernateException, SQLException { Criteria criteria = session.createCriteria ( NetworkUsage.class); criteria.setProjection (Projections.sum ("size")); criteria.add (Restrictions.eq ("isDownload", true)); criteria.add (Restrictions.eq ("user", user)); criteria.add (Restrictions.gt ("date", date)); return (Long) criteria.uniqueResult (); } }); return (result == null) ? 0 : result; }  int countDownloadByUserSince(final User user, final Date date); long getDownloadedSizeByUserSince(final User user, final Date date); }
NetworkUsageDao extends HibernateDao<NetworkUsage, Long> { public long getDownloadedSizeByUserSince (final User user, final Date date) { Long result = getHibernateTemplate ().execute (new HibernateCallback<Long> () { @Override public Long doInHibernate (Session session) throws HibernateException, SQLException { Criteria criteria = session.createCriteria ( NetworkUsage.class); criteria.setProjection (Projections.sum ("size")); criteria.add (Restrictions.eq ("isDownload", true)); criteria.add (Restrictions.eq ("user", user)); criteria.add (Restrictions.gt ("date", date)); return (Long) criteria.uniqueResult (); } }); return (result == null) ? 0 : result; }  int countDownloadByUserSince(final User user, final Date date); long getDownloadedSizeByUserSince(final User user, final Date date);  }