### Question:
HibernateFolderHistoryDAO extends HibernatePersistentObjectDAO<FolderHistory> implements FolderHistoryDAO { @Override public List<FolderHistory> findByFolderIdAndEvent(long folderId, String event, Date oldestDate) { String query = "_entity.folderId = ?1 and _entity.event = ?2 "; List<Object> values = new ArrayList<Object>(); values.add(folderId); values.add(event); if (oldestDate != null) { query += " and _entity.date >= ?3 "; values.add(oldestDate); } try { return findByWhere(query, values.toArray(new Object[0]), "order by _entity.date asc", null); } catch (PersistenceException e) { log.error(e.getMessage(), e); return new ArrayList<FolderHistory>(); } } private  HibernateFolderHistoryDAO(); @Override List<FolderHistory> findByUserId(long userId); @Override List<FolderHistory> findByFolderId(long folderId); @Override List<FolderHistory> findNotNotified(Integer max); @Override void cleanOldHistories(int ttl); @Override List<FolderHistory> findByUserIdAndEvent(long userId, String event); @Override boolean store(FolderHistory entity); @Override List<FolderHistory> findByPath(String pathExpression, Date olderDate, Collection<String> events,
			Integer max); @Override List<FolderHistory> findByFolderIdAndEvent(long folderId, String event, Date oldestDate);  }### Answer:
@Test public void testFindByFolderIdAndEvent() { List<FolderHistory> histories = dao.findByFolderIdAndEvent(5, "data test 03", null); Assert.assertEquals(1, histories.size()); Date date = histories.get(0).getDate(); Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.add(Calendar.HOUR_OF_DAY, -48); System.out.println(date); System.out.println(cal.getTime()); histories = dao.findByFolderIdAndEvent(5, "data test 03", cal.getTime()); Assert.assertEquals(1, histories.size()); histories = dao.findByFolderIdAndEvent(5, "data test 03", new Date()); Assert.assertEquals(0, histories.size()); }