+
+ @Test
+ public void testEntityPersistenceWithUserTransactions() throws Exception {
+
+ SimpleTransactionManager manager = new SimpleTransactionManager(new DefaultUserTransactionFactory());
+ manager.addResource(jpaTester.getJpaBuilder());
+
+ UserTransaction transaction = manager.getTransaction();
+ transaction.begin();
+
+ EntityManager em = builder.getContextualEntityManager();
+ MyEntity entity = new MyEntity("a", "b");
+ em.persist(entity);
+
+ transaction.commit();
+
+ // Verify one row is written (using Db unit)
+ ITable table = dbtester.getDataSet().getTable("XYZ_MYENTITY");
+ assertEquals(1, table.getRowCount());
+
+ assertEquals("a", table.getValue(0, "SLEUTELTJE"));
+ assertEquals("b", table.getValue(0, "VALUE"));
+
+ // For this simple test, it can also be done through DatabaseUtils
+ assertEquals(1, dbutils.getTableSize("XYZ_MYENTITY"));
+
+ }