class 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();

}