@Test public void testCascadedLazyArgs() { Handle h = dbRule.openHandle(); Update s = h.createUpdate("insert into something (id, name) values (:id, :name)"); Map<String, Object> args = new HashMap<>(); args.put("id", 0); s.bindMap(args); s.bindBean(new Keith()); int insertCount = s.execute(); assertThat(insertCount).isEqualTo(1); Something something = h.createQuery("select id, name from something").mapToBean(Something.class).findOnly(); assertThat(something).isEqualTo(new Something(0, "Keith")); }
@Test public void testMapKeyBinding() { Handle h = dbRule.openHandle(); Update s = h.createUpdate("insert into something (id, name) values (:id, :name)"); Map<String, Object> args = new HashMap<>(); args.put("id", 0); args.put("name", "Keith"); s.bindMap(args); int insertCount = s.execute(); Query q = h.createQuery("select * from something where id = :id").bind("id", 0); final Something fromDb = q.mapToBean(Something.class).findOnly(); assertThat(insertCount).isEqualTo(1); assertThat(fromDb).extracting(Something::getId, Something::getName).containsExactly(0, "Keith"); }
@Test public void testUsefulArgumentOutputForDebug() { expectedException.expect(StatementException.class); expectedException.expectMessage("arguments:{positional:{7:8}, named:{name:brian}, finder:[{one=two},{lazy bean property arguments \"java.lang.Object"); h.createUpdate("insert into something (id, name) values (:id, :name)") .bind("name", "brian") .bind(7, 8) .bindMap(new HandyMapThing<String>().add("one", "two")) .bindBean(new Object()) .execute(); }