/** * Removes the entity in the database avoiding an insertion error and inserts a new entity to make * the tests. */ public void startup() { removeEntity(); EBStore ebstore = new EBStore(); ebstore.setId(ENTITY_ID.intValue()); ebstore.setName(ENTITY_NAME); entityManager.persist(ebstore); }
/** * Sets the flush mode to COMMIT and verifies if the container does not make a flush when a query * method is called.The flush must be called only in the commit. */ @TransactionAttribute(TransactionAttributeType.REQUIRED) public void setFlushModeCommit() { entityManager.setFlushMode(FlushModeType.COMMIT); assertEquals(entityManager.getFlushMode(), FlushModeType.COMMIT, "The flush mode was not set."); EBStore ebstoreBeforeChange = entityManager.find(EBStore.class, ENTITY_ID); ebstoreBeforeChange.setName(ENTITY_NAME_2); // forces a flush entityManager.createQuery("SELECT e FROM EBStore e"); // verifies if the flush was not made EBStore ebstoreAfterChange = entityManager.find(EBStore.class, ENTITY_ID); assertEquals( ebstoreAfterChange.getName(), ENTITY_NAME, "The container made a flush after the query"); }