Program: 5906
Project: 5906
Buggy source:
public void testUnidirectionalCollection() throws Exception {
  final Session session=openSession();
  Transaction transaction=session.beginTransaction();
  SnowFlake sf=new SnowFlake();
  sf.setDescription("String_Node_Str");
  session.save(sf);
  SnowFlake sf2=new SnowFlake();
  sf.setDescription("String_Node_Str");
  session.save(sf2);
  Cloud cloud=new Cloud();
  cloud.setLength(23);
  cloud.getProducedSnowFlakes().add(sf);
  cloud.getProducedSnowFlakes().add(sf2);
  session.persist(cloud);
  transaction.commit();
  session.clear();
  transaction=session.beginTransaction();
  cloud=(Cloud)session.get(Cloud.class,cloud.getId());
  assertNotNull(cloud.getProducedSnowFlakes());
  assertEquals(2,cloud.getProducedSnowFlakes().size());
  final SnowFlake removedSf=cloud.getProducedSnowFlakes().iterator().next();
  SnowFlake sf3=new SnowFlake();
  sf3.setDescription("String_Node_Str");
  session.persist(sf3);
  cloud.getProducedSnowFlakes().remove(removedSf);
  cloud.getProducedSnowFlakes().add(sf3);
  transaction.commit();
  session.clear();
  transaction=session.beginTransaction();
  cloud=(Cloud)session.get(Cloud.class,cloud.getId());
  assertNotNull(cloud.getProducedSnowFlakes());
  assertEquals(2,cloud.getProducedSnowFlakes().size());
  boolean present=false;
  for (  SnowFlake current : cloud.getProducedSnowFlakes()) {
    if (current.getDescription().equals(removedSf.getDescription())) {
      present=true;
    }
  }
  assertFalse("String_Node_Str",present);
  for (  SnowFlake current : cloud.getProducedSnowFlakes()) {
    session.delete(current);
  }
  session.delete(session.load(SnowFlake.class,removedSf.getId()));
  cloud.getProducedSnowFlakes().clear();
  transaction.commit();
  session.clear();
  transaction=session.beginTransaction();
  cloud=(Cloud)session.get(Cloud.class,cloud.getId());
  assertNotNull(cloud.getProducedSnowFlakes());
  assertEquals(0,cloud.getProducedSnowFlakes().size());
  session.delete(cloud);
  transaction.commit();
  session.close();
}

Fixed version (ground truth):
public void testUnidirectionalCollection() throws Exception {
  final Session session=openSession();
  Transaction transaction=session.beginTransaction();
  SnowFlake sf=new SnowFlake();
  sf.setDescription("String_Node_Str");
  session.save(sf);
  SnowFlake sf2=new SnowFlake();
  sf2.setDescription("String_Node_Str");
  session.save(sf2);
  Cloud cloud=new Cloud();
  cloud.setLength(23);
  cloud.getProducedSnowFlakes().add(sf);
  cloud.getProducedSnowFlakes().add(sf2);
  session.persist(cloud);
  transaction.commit();
  session.clear();
  transaction=session.beginTransaction();
  cloud=(Cloud)session.get(Cloud.class,cloud.getId());
  assertNotNull(cloud.getProducedSnowFlakes());
  assertEquals(2,cloud.getProducedSnowFlakes().size());
  final SnowFlake removedSf=cloud.getProducedSnowFlakes().iterator().next();
  SnowFlake sf3=new SnowFlake();
  sf3.setDescription("String_Node_Str");
  session.persist(sf3);
  cloud.getProducedSnowFlakes().remove(removedSf);
  cloud.getProducedSnowFlakes().add(sf3);
  transaction.commit();
  session.clear();
  transaction=session.beginTransaction();
  cloud=(Cloud)session.get(Cloud.class,cloud.getId());
  assertNotNull(cloud.getProducedSnowFlakes());
  assertEquals(2,cloud.getProducedSnowFlakes().size());
  boolean present=false;
  for (  SnowFlake current : cloud.getProducedSnowFlakes()) {
    if (current.getDescription().equals(removedSf.getDescription())) {
      present=true;
    }
  }
  assertFalse("String_Node_Str",present);
  for (  SnowFlake current : cloud.getProducedSnowFlakes()) {
    session.delete(current);
  }
  session.delete(session.load(SnowFlake.class,removedSf.getId()));
  cloud.getProducedSnowFlakes().clear();
  transaction.commit();
  session.clear();
  transaction=session.beginTransaction();
  cloud=(Cloud)session.get(Cloud.class,cloud.getId());
  assertNotNull(cloud.getProducedSnowFlakes());
  assertEquals(0,cloud.getProducedSnowFlakes().size());
  session.delete(cloud);
  transaction.commit();
  session.close();
}