Skip to content

Instantly share code, notes, and snippets.

Created January 8, 2013 04:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/a3f07cf467e83bdbcda8 to your computer and use it in GitHub Desktop.
Save anonymous/a3f07cf467e83bdbcda8 to your computer and use it in GitHub Desktop.
try {
new Thread() {
public void run() {
try {
TransactionManager transactionManager = TestingJtaPlatformImpl.INSTANCE.getTransactionManager();
transactionManager.setTransactionTimeout( 5 );
transactionManager.begin();
EntityManager em = entityManagerFactory().createEntityManager();
DataPoint dp = new DataPoint();
dp.name = "foo";
em.persist( dp );
long id = dp.id;
TestingJtaPlatformImpl.tryCommit();
em.close();
transactionManager.begin();
em = entityManagerFactory().createEntityManager();
dp = em.find( DataPoint.class, id );
System.out.println("FOUND dp: " + dp.name);
em.remove( dp );
TestingJtaPlatformImpl.tryCommit();
em.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}.start();
Thread.sleep( 30000 );
} catch (Exception e) {
e.printStackTrace();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment