示例#1
0
  @Before
  public void populate() throws Exception {
    queryTemplate.run(
        new UpdateQuery() {
          @Override
          public Integer perform(DatabaseConnection connection) throws Exception {
            int affectedRows = 0;

            affectedRows +=
                connection.executeUpdate(
                    "INSERT INTO Person (id, name, birthday, employed) VALUES (?, ?, ?, ?)",
                    1,
                    "John",
                    johnBirthday,
                    true);
            affectedRows +=
                connection.executeUpdate(
                    "INSERT INTO Person (id, name, birthday, employed) VALUES (?, ?, ?, ?)",
                    2,
                    "Doe",
                    doeBirthday,
                    false);

            return affectedRows;
          }
        },
        true);

    DatabaseConnection.clearCache();
  }