@Test public void testTxActuallyCommits() throws Exception { Handle h2 = dbi.open(); Dao one = handle.attach(Dao.class); Dao two = h2.attach(Dao.class); // insert in @Transaction method Something inserted = one.insertAndFetch(1, "Brian"); // fetch from another connection Something fetched = two.findById(1); assertThat(fetched, equalTo(inserted)); }
@Test public void testTx() throws Exception { Dao dao = handle.attach(Dao.class); Something s = dao.insertAndFetch(1, "Ian"); assertThat(s, equalTo(new Something(1, "Ian"))); }