Exemplo n.º 1
0
  @Test
  public void readTest() throws Exception {
    Person person =
        queryTemplate.run(
            new Query<Person>() {
              @Override
              public Person perform(DatabaseConnection connection) throws Exception {
                return connection.read(Person.class, 1);
              }
            },
            false);

    Assert.assertEquals("John", person.getName());
    Assert.assertEquals(johnBirthday, person.getBirthday());
  }
Exemplo n.º 2
0
  @Test
  public void executeQueryTest() throws Exception {
    String expectedName = "John";
    final int joeId = 1;
    Person person =
        queryTemplate.run(
            new Query<Person>() {
              @Override
              public Person perform(DatabaseConnection connection) throws Exception {
                return connection.executeQuery(
                    "SELECT * FROM Person WHERE id = ?", Person.class, joeId);
              }
            },
            false);

    Assert.assertNotNull(person);
    Assert.assertEquals(expectedName, person.getName());
  }