Package org.skife.jdbi.v2

Examples of org.skife.jdbi.v2.Handle.createQuery()


                .bind("column_one", 7)
                .bind("column_two", "Rebecca")
                .execute();
        assertEquals(1, count);

        final String name = h.createQuery("select name from something where id = 7")
                .map(StringMapper.FIRST)
                .first();
        assertEquals(name, "Rebecca");
    }
View Full Code Here


            fail("unexpected exception");
        }

        final Handle h = DBI.open(derby);

        int count = h.createQuery("select count(*) from something").map(new IntegerMapper()).first();

        assertEquals(0, count);
        h.close();
    }

View Full Code Here

                            public void call(IDBI inner)
                            {
                                final Handle h = DBIUtil.getHandle(inner);
                                h.insert("insert into something (id, name) values (8, 'ignored again')");

                                int count = h.createQuery("select count(*) from something").map(new IntegerMapper()).first();
                                assertEquals(2, count);
                                throw new ForceRollback();
                            }
                        });
                        fail("should have thrown an exception");
View Full Code Here

                        fail("should have thrown an exception");
                    }
                    catch (ForceRollback e) {
                        assertTrue(true);
                    }
                    int count = h.createQuery("select count(*) from something").map(new IntegerMapper()).first();
                    assertEquals(1, count);
                    throw new ForceRollback();
                }
            });
            fail("should have thrown an exception");
View Full Code Here

        service.inPropagationRequired(new Callback()
        {
            public void call(IDBI dbi)
            {
                final Handle h = DBIUtil.getHandle(dbi);
                int count = h.createQuery("select count(*) from something").map(new IntegerMapper()).first();
                assertEquals(0, count);
            }
        });
    }

View Full Code Here

                    service.inRequiresNewReadUncommitted(new Callback()
                    {
                        public void call(IDBI inner)
                        {
                            final Handle h = DBIUtil.getHandle(inner);
                            int count = h.createQuery("select count(*) from something").map(new IntegerMapper()).first();
                            assertEquals(1, count);
                            h.insert("insert into something (id, name) values (8, 'ignored again')");
                            throw new ForceRollback();
                        }
                    });
View Full Code Here

                }
                catch (ForceRollback e) {
                    assertTrue(true);
                }

                int count = h.createQuery("select count(*) from something").map(new IntegerMapper()).first();
                assertEquals(1, count);
            }
        });
    }
}
View Full Code Here

    @Test
    public void createsAValidDBI() throws Exception {
        final Handle handle = dbi.open();

        final Query<String> names = handle.createQuery("SELECT name FROM people WHERE age < ?")
                                          .bind(0, 50)
                                          .map(StringMapper.FIRST);
        assertThat(ImmutableList.copyOf(names))
                .containsOnly("Coda Hale", "Kris Gale");
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.