All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.ebeaninternal.server.query.CallableQueryIds Maven / Gradle / Ivy

There is a newer version: 15.8.0
Show newest version
package io.ebeaninternal.server.query;

import io.ebeaninternal.api.SpiEbeanServer;
import io.ebeaninternal.api.SpiQuery;

import java.util.List;
import java.util.concurrent.Callable;

/**
 * Represent the fetch Id's query as a Callable.
 */
public final class CallableQueryIds extends CallableQuery implements Callable> {

  private final boolean createdTransaction;

  public CallableQueryIds(SpiEbeanServer server, SpiQuery query, boolean createdTransaction) {
    super(server, query);
    this.createdTransaction = createdTransaction;
  }

  /**
   * Execute the find Id's query returning the list of Id's.
   */
  @Override
  public List call() {
    // we have already made a copy of the query
    // this way the same query instance is available to the
    // QueryFutureIds (as so has access to the List before it is done)
    try {
      return server.findIdsWithCopy(query);
    } finally {
      if (createdTransaction) {
        transaction.end();
      }
    }
  }

}