use of org.jdbi.v3.core.Something in project jdbi by jdbi.
the class TestMixinInterfaces method testInTransactionWithLevel.
@Test
public void testInTransactionWithLevel() throws Exception {
TransactionStuff txl = handle.attach(TransactionStuff.class);
txl.insert(7, "Keith");
Something s = txl.inTransaction(TransactionIsolationLevel.SERIALIZABLE, conn -> {
assertThat(conn.getHandle().getTransactionIsolationLevel()).isEqualTo(TransactionIsolationLevel.SERIALIZABLE);
return conn.byId(7);
});
assertThat(s.getName()).isEqualTo("Keith");
}
use of org.jdbi.v3.core.Something in project jdbi by jdbi.
the class TestNewApiOnDbiAndHandle method testAttach.
@Test
public void testAttach() throws Exception {
Spiffy spiffy = handle.attach(Spiffy.class);
spiffy.insert(new Something(1, "Tim"));
spiffy.insert(new Something(2, "Diego"));
assertThat(spiffy.findNameById(2)).isEqualTo("Diego");
}
use of org.jdbi.v3.core.Something in project jdbi by jdbi.
the class TestBatching method testInsertSingleIterable.
@Test
public void testInsertSingleIterable() throws Exception {
UsesBatching b = handle.attach(UsesBatching.class);
List<Something> to_insert = Arrays.asList(new Something(1, "Tom"), new Something(2, "Tatu"));
int[] counts = b.insertBeans(to_insert);
assertThat(counts).containsExactly(1, 1);
assertThat(b.size()).isEqualTo(2);
}
use of org.jdbi.v3.core.Something in project jdbi by jdbi.
the class TestBatching method testNoIterable.
@Test(expected = UnableToCreateStatementException.class, timeout = 5000)
public void testNoIterable() throws Exception {
BadBatch b = handle.attach(BadBatch.class);
b.insertBeans(new Something(1, "x"));
}
use of org.jdbi.v3.core.Something in project jdbi by jdbi.
the class TestBatching method testChunkedBatchingOnParam.
@Test
public void testChunkedBatchingOnParam() throws Exception {
UsesBatching b = handle.attach(UsesBatching.class);
List<Something> things = Arrays.asList(new Something(1, "Brian"), new Something(2, "Henri"), new Something(3, "Patrick"), new Something(4, "Robert"), new Something(5, "Maniax"));
int[] counts = b.insertChunked(3, things);
assertThat(counts).hasSize(5).containsOnly(1);
}
Aggregations