@Override
  public void delete() {
    Long id = 1L;
    FileScanner element = dao.read(id);
    Set<Collection> collections = element.getCollections();
    Hibernate.initialize(collections);
    dao.delete(element);

    assertEquals(dao.count(), (howMany() - 1));
    assertNull(dao.read(id));
    for (Collection collection : collections) {
      assertNotNull(cdao.read(collection.getUUID()));
    }
  }
  @Test
  public void deleteProductReferences() {
    Long fid0 = Long.valueOf(0);
    Long fid1 = Long.valueOf(1);
    FileScanner fs0 = dao.read(fid0);
    FileScanner fs1 = dao.read(fid1);
    Collection c = cdao.read("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1");

    assertTrue(fs0.getCollections().contains(c));
    assertTrue(fs1.getCollections().contains(c));

    int updated = dao.deleteCollectionReferences(c);
    dao.getSessionFactory().getCurrentSession().refresh(fs0);
    dao.getSessionFactory().getCurrentSession().refresh(fs1);

    assertEquals(updated, 2);
    assertFalse(fs0.getCollections().contains(c));
    assertFalse(fs1.getCollections().contains(c));
  }