ManifestFileRecordCurator extends AbstractHibernateCurator<ManifestFileRecord> { @Transactional public int deleteExpired(Date expiryDate) { String queryString = String.format("delete from %s r where r.created < :expiry", QUERY_CLASS_NAME); Query q = getEntityManager().createQuery(queryString); q.setParameter("expiry", expiryDate); return q.executeUpdate(); } ManifestFileRecordCurator(); @Transactional boolean deleteById(String id); ManifestFileRecord findFile(String id); @Transactional ManifestFileRecord createFile(ManifestFileType type, File fileToStore, String principalName,
        String targetId); @Transactional int deleteExpired(Date expiryDate); int deleteMatching(ManifestFileType type, String targetId);  }
@Test public void testDeleteExpired() throws Exception { Calendar cal = Calendar.getInstance(); curator.createFile(ManifestFileType.EXPORT, tempFile, "principalId", "ownerId"); cal.add(Calendar.HOUR_OF_DAY, -4); assertEquals(0, curator.deleteExpired(cal.getTime())); cal.add(Calendar.HOUR_OF_DAY, 8); assertEquals(2, curator.deleteExpired(cal.getTime())); }