class GenericDAO {

    public void update(PK id, T model) {
        try (Connection connection = connectionProvider.get()) {
            Map<?, ?> map = MAPPER.map(model);
            Map<String, ?> result = R.table(tableName).get(id).update(map).run(connection);

            if (((Long) result.get("errors")) > 0) {
                throw new ReqlClientError("Failed to update model. %s", ((String) result.get("first_error")).split("\n")[0]);
            }
        }
    }

}

class GenericDAOTest {

    private static RethinkDB r;
    private GenericDAO<TestModel, String> dao;

    @Test
    public void update() {

        TestModel model = new TestModel("1");
        dao.create(model);

        model.sub = new TestModel.SubModel();
        model.sub.name = "test";
        dao.update(model.id, model);

        assertThat(dao.read("1").get().sub.name).isEqualTo(model.sub.name);
    }

}