io.vertx.mutiny.sqlclient.Tuple Java Examples

The following examples show how to use io.vertx.mutiny.sqlclient.Tuple. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HibernateReactiveDB2TestEndpoint.java    From quarkus with Apache License 2.0 7 votes vote down vote up
private Uni<String> selectNameFromId(Integer id) {
    return db2Pool.preparedQuery("SELECT name FROM Pig WHERE id = ?").execute(Tuple.of(id)).map(rowSet -> {
        if (rowSet.size() == 1) {
            return rowSet.iterator().next().getString(0);
        } else if (rowSet.size() > 1) {
            throw new AssertionError("More than one result returned: " + rowSet.size());
        } else {
            return null; // Size 0
        }
    });
}
 
Example #2
Source File: HibernateReactiveTestEndpoint.java    From quarkus with Apache License 2.0 5 votes vote down vote up
private Uni<String> selectNameFromId(Integer id) {
    return pgPool.preparedQuery("SELECT name FROM Pig WHERE id = $1").execute(Tuple.of(id)).map(rowSet -> {
        if (rowSet.size() == 1) {
            return rowSet.iterator().next().getString(0);
        } else if (rowSet.size() > 1) {
            throw new AssertionError("More than one result returned: " + rowSet.size());
        } else {
            return null; // Size 0
        }
    });
}
 
Example #3
Source File: HibernateReactiveMySQLTestEndpoint.java    From quarkus with Apache License 2.0 5 votes vote down vote up
private Uni<String> selectNameFromId(Integer id) {
    return mysqlPool.preparedQuery("SELECT name FROM Pig WHERE id = ?").execute(Tuple.of(id)).map(rowSet -> {
        if (rowSet.size() == 1) {
            return rowSet.iterator().next().getString(0);
        } else if (rowSet.size() > 1) {
            throw new AssertionError("More than one result returned: " + rowSet.size());
        } else {
            return null; // Size 0
        }
    });
}
 
Example #4
Source File: WorldRepository.java    From FrameworkBenchmarks with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public Uni<World> find(int id) {
    return clients.getClient().preparedQuery("SELECT id, randomNumber FROM World WHERE id = $1")
            .execute(Tuple.of(id))
            .map(rowset -> {
                Row row = rowset.iterator().next();
                return new World(row.getInteger(0), row.getInteger(1));
            });
}
 
Example #5
Source File: WorldRepository.java    From FrameworkBenchmarks with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public Uni<Void> update(World[] worlds) {
    Arrays.sort(worlds);
    List<Tuple> args = new ArrayList<>(worlds.length);
    for (World world : worlds) {
        args.add(Tuple.of(world.getId(), world.getRandomNumber()));
    }
    return clients.getPool().preparedQuery("UPDATE World SET randomNumber = $2 WHERE id = $1")
            .executeBatch(args)
            .map(v -> null);
}
 
Example #6
Source File: Fruit.java    From quarkus-quickstarts with Apache License 2.0 2 votes vote down vote up
public static Uni<Fruit> findById(PgPool client, Long id) {
    return client.preparedQuery("SELECT id, name FROM fruits WHERE id = $1").execute(Tuple.of(id))
            .onItem().apply(RowSet::iterator)
            .onItem().apply(iterator -> iterator.hasNext() ? from(iterator.next()) : null);
}
 
Example #7
Source File: Fruit.java    From quarkus-quickstarts with Apache License 2.0 2 votes vote down vote up
public Uni<Boolean> update(PgPool client) {
    return client.preparedQuery("UPDATE fruits SET name = $1 WHERE id = $2").execute(Tuple.of(name, id))
            .onItem().apply(pgRowSet -> pgRowSet.rowCount() == 1);
}
 
Example #8
Source File: Fruit.java    From quarkus-quickstarts with Apache License 2.0 1 votes vote down vote up
public Uni<Long> save(PgPool client) {
    return client.preparedQuery("INSERT INTO fruits (name) VALUES ($1) RETURNING (id)").execute(Tuple.of(name))
            .onItem().apply(pgRowSet -> pgRowSet.iterator().next().getLong("id"));
}
 
Example #9
Source File: Fruit.java    From quarkus-quickstarts with Apache License 2.0 1 votes vote down vote up
public Uni<Boolean> update(PgPool client) {
    return client.preparedQuery("UPDATE fruits SET name = $1 WHERE id = $2").execute(Tuple.of(name, id))
            .onItem().apply(pgRowSet -> pgRowSet.rowCount() == 1);
}
 
Example #10
Source File: Fruit.java    From quarkus-quickstarts with Apache License 2.0 1 votes vote down vote up
public static Uni<Boolean> delete(PgPool client, Long id) {
    return client.preparedQuery("DELETE FROM fruits WHERE id = $1").execute(Tuple.of(id))
            .onItem().apply(pgRowSet -> pgRowSet.rowCount() == 1);
}
 
Example #11
Source File: Fruit.java    From quarkus-quickstarts with Apache License 2.0 1 votes vote down vote up
public Uni<Long> save(PgPool client) {
    return client.preparedQuery("INSERT INTO fruits (name) VALUES ($1) RETURNING (id)").execute(Tuple.of(name))
            .onItem().apply(pgRowSet -> pgRowSet.iterator().next().getLong("id"));
}
 
Example #12
Source File: Fruit.java    From quarkus-quickstarts with Apache License 2.0 1 votes vote down vote up
public static Uni<Boolean> delete(PgPool client, Long id) {
    return client.preparedQuery("DELETE FROM fruits WHERE id = $1").execute(Tuple.of(id))
            .onItem().apply(pgRowSet -> pgRowSet.rowCount() == 1);
}
 
Example #13
Source File: Fruit.java    From quarkus-quickstarts with Apache License 2.0 votes vote down vote up
public static Uni<Fruit> findById(PgPool client, Long id) {
    return client.preparedQuery("SELECT id, name FROM fruits WHERE id = $1").execute(Tuple.of(id))
            .onItem().apply(RowSet::iterator)
            .onItem().apply(iterator -> iterator.hasNext() ? from(iterator.next()) : null);
}