@Test
  @Priority(10)
  public void initData() {
    EntityManager em = getEntityManager();

    SetRefEdEntity ed1 = new SetRefEdEntity(1, "data_ed_1");

    SetRefIngEntity ing1 = new SetRefIngEntity(3, "data_ing_1");

    // Revision 1
    em.getTransaction().begin();

    em.persist(ed1);

    em.getTransaction().commit();

    // Revision 2

    em.getTransaction().begin();

    ed1 = em.find(SetRefEdEntity.class, ed1.getId());

    em.persist(ing1);

    ed1.setReffering(new HashSet<SetRefIngEntity>());
    ed1.getReffering().add(ing1);

    em.getTransaction().commit();

    //

    ed1_id = ed1.getId();

    ing1_id = ing1.getId();
  }
  @Test
  @TestForIssue(jiraKey = "HHH-6614")
  public void testSessionCacheCollectionClear() {
    final String[] auditEntityNames =
        new String[] {
          "org.hibernate.envers.test.entities.onetomany.SetRefEdEntity_AUD",
          "org.hibernate.envers.test.entities.onetomany.SetRefIngEntity_AUD"
        };

    SetRefEdEntity ed1 = new SetRefEdEntity(1, "data_ed_1");
    SetRefEdEntity ed2 = new SetRefEdEntity(2, "data_ed_2");
    SetRefIngEntity ing1 = new SetRefIngEntity(3, "data_ing_1");
    SetRefIngEntity ing2 = new SetRefIngEntity(4, "data_ing_2");

    getSession().getTransaction().begin();
    getSession().persist(ed1);
    getSession().persist(ed2);
    getSession().persist(ing1);
    getSession().persist(ing2);
    getSession().getTransaction().commit();
    checkEmptyAuditSessionCache(getSession(), auditEntityNames);

    getSession().getTransaction().begin();
    ed1 = (SetRefEdEntity) getSession().load(SetRefEdEntity.class, ed1.getId());
    ing1.setReference(ed1);
    ing2.setReference(ed1);
    getSession().getTransaction().commit();
    checkEmptyAuditSessionCache(getSession(), auditEntityNames);

    getSession().getTransaction().begin();
    ed2 = (SetRefEdEntity) getSession().load(SetRefEdEntity.class, ed2.getId());
    Set<SetRefIngEntity> reffering = new HashSet<SetRefIngEntity>();
    reffering.add(ing1);
    reffering.add(ing2);
    ed2.setReffering(reffering);
    getSession().getTransaction().commit();
    checkEmptyAuditSessionCache(getSession(), auditEntityNames);

    getSession().getTransaction().begin();
    ed2 = (SetRefEdEntity) getSession().load(SetRefEdEntity.class, ed2.getId());
    ed2.getReffering().remove(ing1);
    getSession().getTransaction().commit();
    checkEmptyAuditSessionCache(getSession(), auditEntityNames);

    getSession().getTransaction().begin();
    ed2 = (SetRefEdEntity) getSession().load(SetRefEdEntity.class, ed2.getId());
    ed2.getReffering().iterator().next().setData("mod_data_ing_2");
    getSession().getTransaction().commit();
    checkEmptyAuditSessionCache(getSession(), auditEntityNames);
  }