here's my test, quite simple.
The book class has a generated Integer id, and String title, both with corresponding get/set methods.
Code:
public class BookTest {
   private static EntityManagerFactory entityManagerFactory;
   private EntityManager entityManager;
   @BeforeClass
   public static void setUpBeforeClass() throws Exception {
      try {
         entityManagerFactory = Persistence
               .createEntityManagerFactory("dnd");
      } catch (Exception e) {
         System.out.println(e);
      }
   }
   @AfterClass
   public static void tearDownAfterClass() throws Exception {
      if (entityManagerFactory != null) {
         entityManagerFactory.close();
      }
   }
   @Before
   public void setUp() throws Exception {
      entityManager = entityManagerFactory.createEntityManager();
   }
   @After
   public void tearDown() throws Exception {
      if (entityManager != null) {
         entityManager.close();
      }
   }
   @Test
   public void testPersistBook() {
      Book book = new Book("test");
      entityManager.persist(book);
   }
   @Test
   public void testGetBook() {
      List<Book> books = entityManager.createQuery(
            "from Book b where b.title = 'test'").getResultList();
      assertNotNull(books);
      System.out.println(books.size());
   }
}
The first test works, in that it doesn't throw any exceptions.
The second just shows there are 0 books in the database, and I also just check at the table itself to see it myself.
what can cause it?