Program: 176306
Project: 176306
Buggy source:
@Test public void testNativeQuery(){
  BlogPost p1=prepareBlogPost1();
  BlogPost p2=prepareBlogPost2();
  em.persist(p1);
  em.persist(p2);
  Query q=em.createNativeQuery("String_Node_Str",BlogPost.class);
  List<BlogPost> allPosts=q.getResultList();
  Assert.assertNotNull(allPosts);
  Assert.assertFalse(allPosts.isEmpty());
  Assert.assertEquals(2,allPosts.size());
  assertPost1(allPosts.get(0));
  assertPost2(allPosts.get(1));
  q=em.createNativeQuery("String_Node_Str",BlogPost.class);
  allPosts=q.getResultList();
  Assert.assertNotNull(allPosts);
  Assert.assertFalse(allPosts.isEmpty());
  Assert.assertEquals(1,allPosts.size());
  assertPost1(allPosts.get(0));
  q=em.createNativeQuery("String_Node_Str",BlogPost.class);
  q.executeUpdate();
  q=em.createNativeQuery("String_Node_Str",BlogPost.class);
  q.executeUpdate();
  q=em.createNativeQuery("String_Node_Str",BlogPost.class);
  q.executeUpdate();
  q=em.createNativeQuery("String_Node_Str",BlogPost.class);
  q.executeUpdate();
  q=em.createNativeQuery("String_Node_Str",BlogPost.class);
  allPosts=q.getResultList();
  Assert.assertNotNull(allPosts);
  Assert.assertFalse(allPosts.isEmpty());
  Assert.assertEquals(1,allPosts.size());
  assertUpdatedPost1(allPosts.get(0));
  q=em.createNativeQuery("String_Node_Str",BlogPost.class);
  q.executeUpdate();
  q=em.createNativeQuery("String_Node_Str",BlogPost.class);
  q.executeUpdate();
  q=em.createNativeQuery("String_Node_Str",BlogPost.class);
  q.executeUpdate();
  q=em.createNativeQuery("String_Node_Str",BlogPost.class);
  q.executeUpdate();
  q=em.createNativeQuery("String_Node_Str",BlogPost.class);
  allPosts=q.getResultList();
  Assert.assertNotNull(allPosts);
  Assert.assertFalse(allPosts.isEmpty());
  Assert.assertEquals(1,allPosts.size());
  assertUpdatedPost2(allPosts.get(0));
  q=em.createNativeQuery("String_Node_Str",BlogPost.class);
  q.executeUpdate();
  q=em.createNativeQuery("String_Node_Str",BlogPost.class);
  q.executeUpdate();
  q=em.createNativeQuery("String_Node_Str",BlogPost.class);
  allPosts=q.getResultList();
  Assert.assertTrue(allPosts == null || allPosts.isEmpty());
}

Fixed version (ground truth):
@Test public void testNativeQuery(){
  BlogPost p1=prepareBlogPost1();
  BlogPost p2=prepareBlogPost2();
  em.persist(p1);
  em.persist(p2);
  Query q=em.createNativeQuery("String_Node_Str",BlogPost.class);
  List<BlogPost> allPosts=q.getResultList();
  Assert.assertNotNull(allPosts);
  Assert.assertFalse(allPosts.isEmpty());
  Assert.assertEquals(2,allPosts.size());
  assertPost1(allPosts.get(0));
  assertPost2(allPosts.get(1));
  q=em.createNativeQuery("String_Node_Str",BlogPost.class);
  allPosts=q.getResultList();
  Assert.assertNotNull(allPosts);
  Assert.assertFalse(allPosts.isEmpty());
  Assert.assertEquals(1,allPosts.size());
  assertPost1(allPosts.get(0));
  q=em.createNativeQuery("String_Node_Str",BlogPost.class);
  q.executeUpdate();
  q=em.createNativeQuery("String_Node_Str",BlogPost.class);
  q.executeUpdate();
  q=em.createNativeQuery("String_Node_Str",BlogPost.class);
  q.executeUpdate();
  q=em.createNativeQuery("String_Node_Str",BlogPost.class);
  q.executeUpdate();
  q=em.createNativeQuery("String_Node_Str",BlogPost.class);
  allPosts=q.getResultList();
  Assert.assertNotNull(allPosts);
  Assert.assertFalse(allPosts.isEmpty());
  Assert.assertEquals(1,allPosts.size());
  assertUpdatedPost1(allPosts.get(0));
  q=em.createNativeQuery("String_Node_Str",BlogPost.class);
  q.executeUpdate();
  q=em.createNativeQuery("String_Node_Str",BlogPost.class);
  q.executeUpdate();
  q=em.createNativeQuery("String_Node_Str",BlogPost.class);
  q.executeUpdate();
  q=em.createNativeQuery("String_Node_Str",BlogPost.class);
  q.executeUpdate();
  q=em.createNativeQuery("String_Node_Str",BlogPost.class);
  allPosts=q.getResultList();
  Assert.assertNotNull(allPosts);
  Assert.assertFalse(allPosts.isEmpty());
  Assert.assertEquals(1,allPosts.size());
  assertUpdatedPost2(allPosts.get(0));
  q=em.createNativeQuery("String_Node_Str",BlogPost.class);
  allPosts=q.getResultList();
  Assert.assertNotNull(allPosts);
  Assert.assertFalse(allPosts.isEmpty());
  Assert.assertEquals(1,allPosts.size());
  assertUpdatedPost1(allPosts.get(0));
  q=em.createNativeQuery("String_Node_Str",BlogPost.class);
  q.executeUpdate();
  q=em.createNativeQuery("String_Node_Str",BlogPost.class);
  q.executeUpdate();
  q=em.createNativeQuery("String_Node_Str",BlogPost.class);
  allPosts=q.getResultList();
  Assert.assertTrue(allPosts == null || allPosts.isEmpty());
}