Skip to content

Commit

Permalink
Use a transaction scoped EntityManager to set/get FlushMode
Browse files Browse the repository at this point in the history
Signed-off-by: Jean-Louis Monteiro <jlmonteiro@tomitribe.com>
  • Loading branch information
jeanouii committed Apr 6, 2021
1 parent f4102ff commit 6df5c25
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/com/sun/ts/tests/jpa/core/enums/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import jakarta.persistence.CascadeType;
import jakarta.persistence.DiscriminatorType;
import jakarta.persistence.EntityManager;
import jakarta.persistence.EntityTransaction;
import jakarta.persistence.EnumType;
import jakarta.persistence.FetchType;
import jakarta.persistence.FlushModeType;
Expand Down Expand Up @@ -975,6 +976,8 @@ public void flushModeTypeValuesTest() throws Fault {
public void setgetFlushModeEntityManagerTest() throws Fault {
boolean pass = true;
try {
EntityTransaction t = getEntityTransaction();
t.begin();
EntityManager em = getEntityManager();
TestUtil.logTrace("Checking Default mode");
FlushModeType fmt = em.getFlushMode();
Expand Down Expand Up @@ -1005,6 +1008,15 @@ public void setgetFlushModeEntityManagerTest() throws Fault {
} catch (Exception e) {
TestUtil.logErr("Caught exception: ", e);
pass = false;

} finally {
try {
if (getEntityTransaction().isActive()) {
getEntityTransaction().rollback();
}
} catch (Exception fe) {
TestUtil.logErr("Unexpected exception rolling back TX:", fe);
}
}

if (!pass)
Expand Down

0 comments on commit 6df5c25

Please sign in to comment.