Search in sources :

Example 1 with World

use of io.quarkus.benchmark.model.World in project FrameworkBenchmarks by TechEmpower.

the class WorldRepository method updateAll.

@Transactional
public void updateAll(Collection<World> worlds) {
    try (Session s = sf.openSession()) {
        s.setJdbcBatchSize(worlds.size());
        s.setHibernateFlushMode(FlushMode.MANUAL);
        for (World w : worlds) {
            s.update(w);
        }
        s.flush();
    }
}
Also used : World(io.quarkus.benchmark.model.World) StatelessSession(org.hibernate.StatelessSession) Session(org.hibernate.Session) Transactional(javax.transaction.Transactional)

Example 2 with World

use of io.quarkus.benchmark.model.World in project FrameworkBenchmarks by TechEmpower.

the class WorldRepository method update.

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);
}
Also used : ArrayList(java.util.ArrayList) World(io.quarkus.benchmark.model.World) Tuple(io.vertx.mutiny.sqlclient.Tuple)

Example 3 with World

use of io.quarkus.benchmark.model.World in project FrameworkBenchmarks by TechEmpower.

the class WorldRepository method createData.

/**
 * This method is not required (nor specified) by the benchmark rules,
 * but is quite handy to seed a local database and be able to experiment
 * with the app locally.
 */
@Transactional
public void createData() {
    try (StatelessSession statelessSession = sf.openStatelessSession()) {
        final ThreadLocalRandom random = ThreadLocalRandom.current();
        for (int i = 1; i <= 10000; i++) {
            final World world = new World();
            world.setId(i);
            world.setRandomNumber(1 + random.nextInt(10000));
            statelessSession.insert(world);
        }
    }
}
Also used : StatelessSession(org.hibernate.StatelessSession) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) World(io.quarkus.benchmark.model.World) Transactional(javax.transaction.Transactional)

Aggregations

World (io.quarkus.benchmark.model.World)3 Transactional (javax.transaction.Transactional)2 StatelessSession (org.hibernate.StatelessSession)2 Tuple (io.vertx.mutiny.sqlclient.Tuple)1 ArrayList (java.util.ArrayList)1 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)1 Session (org.hibernate.Session)1