use of org.jdbi.v3.core.Something in project jdbi by jdbi.
the class TestNamedParams method testFunctionsBinding.
@Test
public void testFunctionsBinding() throws Exception {
Handle h = dbRule.openHandle();
assertThat(h.createUpdate("insert into something (id, name) values (:id, :name)").bindMethods(new NoArgFunctions(0, "Keith")).execute()).isEqualTo(1);
assertThat(h.select("select * from something where id = ?", 0).mapToBean(Something.class).findOnly()).isEqualTo(new Something(0, "Keith"));
}
use of org.jdbi.v3.core.Something in project jdbi by jdbi.
the class TestNamedParams method testBeanPropertyPrefixBinding.
@Test
public void testBeanPropertyPrefixBinding() throws Exception {
Handle h = dbRule.openHandle();
Something original = new Something(0, "Keith");
assertThat(h.createUpdate("insert into something (id, name) values (:my.id, :my.name)").bindBean("my", original).execute()).isEqualTo(1);
assertThat(h.select("select * from something where id = ?", original.getId()).mapToBean(Something.class).findOnly()).isEqualTo(original);
}
use of org.jdbi.v3.core.Something in project jdbi by jdbi.
the class TestNamedParams method testFieldsPrefixBinding.
@Test
public void testFieldsPrefixBinding() throws Exception {
Handle h = dbRule.openHandle();
assertThat(h.createUpdate("insert into something (id, name) values (:my.id, :my.name)").bindFields("my", new PublicFields(0, "Keith")).execute()).isEqualTo(1);
assertThat(h.select("select * from something where id = ?", 0).mapToBean(Something.class).findOnly()).isEqualTo(new Something(0, "Keith"));
}
use of org.jdbi.v3.core.Something in project jdbi by jdbi.
the class TestNamedParams method testFieldsNestedBinding.
@Test
public void testFieldsNestedBinding() throws Exception {
Handle h = dbRule.openHandle();
assertThat(h.createUpdate("insert into something (id, name) values (:my.nested.id, :my.nested.name)").bindFields("my", new Object() {
@SuppressWarnings("unused")
public PublicFields nested = new PublicFields(0, "Keith");
}).execute()).isEqualTo(1);
assertThat(h.select("select * from something where id = ?", 0).mapToBean(Something.class).findOnly()).isEqualTo(new Something(0, "Keith"));
}
use of org.jdbi.v3.core.Something in project jdbi by jdbi.
the class TestNamedParams method testBeanPropertyBinding.
@Test
public void testBeanPropertyBinding() throws Exception {
Handle h = dbRule.openHandle();
Something original = new Something(0, "Keith");
assertThat(h.createUpdate("insert into something (id, name) values (:id, :name)").bindBean(original).execute()).isEqualTo(1);
assertThat(h.select("select * from something where id = ?", original.getId()).mapToBean(Something.class).findOnly()).isEqualTo(original);
}
Aggregations