Codota Logo
DBI.inTransaction
Code IndexAdd Codota to your IDE (free)

How to use
inTransaction
method
in
org.skife.jdbi.v2.DBI

Best Java code snippets using org.skife.jdbi.v2.DBI.inTransaction (Showing top 20 results out of 315)

  • Common ways to obtain DBI
private void myMethod () {
DBI d =
  • Codota IconDataSource dataSource;new DBI(dataSource)
  • Codota IconConnectionFactory connectionFactory;new DBI(connectionFactory)
  • Codota IconString url;String username;String password;new DBI(url, username, password)
  • Smart code suggestions by Codota
}
origin: apache/incubator-druid

@Override
public void deleteSegments(final Set<DataSegment> segments)
{
 connector.getDBI().inTransaction(
   new TransactionCallback<Void>()
   {
    @Override
    public Void inTransaction(Handle handle, TransactionStatus transactionStatus)
    {
     for (final DataSegment segment : segments) {
      deleteSegment(handle, segment);
     }
     return null;
    }
   }
 );
}
origin: apache/incubator-druid

@Override
public void updateSegmentMetadata(final Set<DataSegment> segments)
{
 connector.getDBI().inTransaction(
   new TransactionCallback<Void>()
   {
    @Override
    public Void inTransaction(Handle handle, TransactionStatus transactionStatus) throws Exception
    {
     for (final DataSegment segment : segments) {
      updatePayload(handle, segment);
     }
     return null;
    }
   }
 );
}
origin: apache/incubator-druid

public <T> T retryTransaction(final TransactionCallback<T> callback, final int quietTries, final int maxTries)
{
 try {
  return RetryUtils.retry(() -> getDBI().inTransaction(TransactionIsolationLevel.READ_COMMITTED, callback), shouldRetry, quietTries, maxTries);
 }
 catch (Exception e) {
  throw Throwables.propagate(e);
 }
}
origin: apache/incubator-druid

return getDBI().inTransaction(
  new TransactionCallback<Void>()
origin: apache/incubator-druid

return getDBI().inTransaction(
  new TransactionCallback<Boolean>()
origin: apache/incubator-druid

 @Override
 public boolean insertDataSourceMetadata(String dataSource, DataSourceMetadata metadata)
 {
  return 1 == connector.getDBI().inTransaction(
    (handle, status) -> handle
      .createStatement(
        StringUtils.format(
          "INSERT INTO %s (dataSource, created_date, commit_metadata_payload, commit_metadata_sha1) VALUES" +
          " (:dataSource, :created_date, :commit_metadata_payload, :commit_metadata_sha1)",
          dbTables.getDataSourceTable()
        )
      )
      .bind("dataSource", dataSource)
      .bind("created_date", DateTimes.nowUtc().toString())
      .bind("commit_metadata_payload", jsonMapper.writeValueAsBytes(metadata))
      .bind("commit_metadata_sha1", BaseEncoding.base16().encode(
        Hashing.sha1().hashBytes(jsonMapper.writeValueAsBytes(metadata)).asBytes()))
      .execute()
  );
 }
}
origin: apache/incubator-druid

@Override
public int deletePendingSegments(String dataSource, Interval deleteInterval)
{
 return connector.getDBI().inTransaction(
   (handle, status) -> handle
     .createStatement(
       StringUtils.format(
         "delete from %s where datasource = :dataSource and created_date >= :start and created_date < :end",
         dbTables.getPendingSegmentsTable()
       )
     )
     .bind("dataSource", dataSource)
     .bind("start", deleteInterval.getStart().toString())
     .bind("end", deleteInterval.getEnd().toString())
     .execute()
 );
}
origin: apache/hive

 Configuration conf,
 DataSegmentPusher dataSegmentPusher) throws CallbackFailedException {
return connector.getDBI().inTransaction((handle, transactionStatus) -> {
origin: rakam-io/rakam

@PostConstruct
public void setup() {
  dbi.inTransaction((Handle handle, TransactionStatus transactionStatus) -> {
    handle.createStatement("CREATE TABLE IF NOT EXISTS project (" +
        "  name TEXT NOT NULL,\n" +
        "  PRIMARY KEY (name))")
        .execute();
    return null;
  });
}
origin: rakam-io/rakam

private void setupTables() {
  dbi.inTransaction((Handle handle, TransactionStatus transactionStatus) -> {
    handle.createStatement("CREATE TABLE IF NOT EXISTS project (" +
        "  name VARCHAR(255) NOT NULL, \n" +
        "  PRIMARY KEY (name))")
        .execute();
    return null;
  });
}
origin: rakam-io/rakam

private void setup() {
  dbi.inTransaction((handle, transactionStatus) -> {
    handle.createStatement("CREATE TABLE IF NOT EXISTS automation_rules (" +
        "  id SERIAL," +
        "  is_active BOOLEAN NOT NULL," +
        "  project TEXT NOT NULL," +
        "  event_filters TEXT NOT NULL," +
        "  actions TEXT NOT NULL," +
        "  custom_data TEXT," +
        "  PRIMARY KEY (id)" +
        "  )")
        .execute();
    return null;
  });
}
origin: rakam-io/rakam

@JsonRequest
@ApiOperation(value = "Update dashboard items")
@Path("/update_dashboard_items")
@ProtectEndpoint(writeOperation = true)
public SuccessMessage updateDashboard(
    @Named("user_id") Project project,
    @ApiParam("dashboard") int dashboard,
    @ApiParam("items") List<DashboardItem> items) {
  dbi.inTransaction((handle, transactionStatus) -> {
    Long execute = handle.createQuery("SELECT id FROM dashboard WHERE id = :id AND project_id = :project")
        .bind("id", dashboard)
        .bind("project", project.project)
        .map(LongMapper.FIRST).first();
    if (execute == null) {
      throw new RakamException(HttpResponseStatus.NOT_FOUND);
    }
    for (DashboardItem item : items) {
      // TODO: verify dashboard is in project
      handle.createStatement("UPDATE dashboard_items SET name = :name, directive = :directive, options = :options WHERE id = :id")
          .bind("id", item.id)
          .bind("name", item.name)
          .bind("directive", item.directive)
          .bind("options", JsonHelper.encode(item.options))
          .execute();
    }
    return null;
  });
  return SuccessMessage.success();
}
origin: rakam-io/rakam

  @ApiParam(value = "refresh_interval", required = false) Duration refreshDuration,
  @ApiParam("options") Map<String, Object> options) {
dbi.inTransaction((handle, transactionStatus) -> {
  if (sharedEveryone != null && !sharedEveryone) {
    handle.createStatement("DELETE FROM dashboard_permission WHERE dashboard = :dashboard")
origin: rakam-io/rakam

dbi.inTransaction((Handle handle, TransactionStatus transactionStatus) -> {
  Integer apiKeyId = saveApiKeys(handle, userId, projectId, keys.readKey(), keys.writeKey(), keys.masterKey());
origin: io.druid/druid-server

 @Override
 public T call() throws Exception
 {
  return getDBI().inTransaction(callback);
 }
};
origin: com.palantir.atlasdb/atlasdb-rdbms

@Override
public void truncateTable(final String tableName) throws InsufficientConsistencyException {
  getDbi().inTransaction(new TransactionCallback<Void>() {
    @Override
    public Void inTransaction(Handle handle, TransactionStatus status) throws Exception {
      handle.execute("TRUNCATE TABLE " + USR_TABLE(tableName));
      return null;
    }
  });
}
origin: io.syndesis/filestore

public SqlIconFileStore(DBI dbi) {
  this.dbi = dbi;
  this.databaseKind = dbi.inTransaction((h, s) -> {
    String dbName = h.getConnection().getMetaData().getDatabaseProductName();
    return DatabaseKind.valueOf(dbName.replace(" ", "_"));
  });
}
origin: io.syndesis.rest/rest-filestore

public String writeTemporaryFile(InputStream file) {
  Objects.requireNonNull(file, "file cannot be null");
  try {
    return dbi.inTransaction((h, status) -> {
      String path = newRandomTempFilePath();
      doWrite(h, path, file);
      return path;
    });
  } catch (CallbackFailedException ex) {
    throw new DaoException("Unable to write on temporary path", ex);
  }
}
origin: io.syndesis.server/server-filestore

public void write(String path, InputStream file) {
  FileStoreSupport.checkValidPath(path);
  Objects.requireNonNull(file, "file cannot be null");
  try {
    dbi.inTransaction((h, status) -> {
      doWrite(h, path, file);
      return true;
    });
  } catch (CallbackFailedException ex) {
    throw new DaoException("Unable to write on path " + path, ex);
  }
}
origin: io.syndesis.server/server-filestore

public boolean delete(String path) {
  FileStoreSupport.checkValidPath(path);
  try {
    return dbi.inTransaction((h, status) -> doDelete(h, path));
  } catch (CallbackFailedException ex) {
    throw new DaoException("Unable to delete path " + path, ex);
  }
}
org.skife.jdbi.v2DBIinTransaction

Javadoc

A convenience function which manages the lifecycle of a handle and yields it to a callback for use by clients. The handle will be in a transaction when the callback is invoked, and that transaction will be committed if the callback finishes normally, or rolled back if the callback raises an exception.

Popular methods of DBI

  • <init>
    Constructor used to allow for obtaining a Connection in a customized manner. The org.skife.jdbi.v2.t
  • open
  • onDemand
    Create a new sql object which will obtain and release connections from this dbi instance, as it need
  • registerMapper
    Register a result set mapper which will have its parameterized type inspected to determine what it m
  • withHandle
    A convenience function which manages the lifecycle of a handle and yields it to a callback for use b
  • registerArgumentFactory
  • setSQLLog
    Specify the class used to log sql statements. Will be passed to all handles created from this instan
  • registerContainerFactory
  • setStatementLocator
    Use a non-standard StatementLocator to look up named statements for all handles created from this DB
  • setStatementRewriter
    Use a non-standard StatementRewriter to transform SQL for all Handle instances created by this DBI.
  • setTransactionHandler
    Specify the TransactionHandler instance to use. This allows overriding transaction semantics, or map
  • setTimingCollector
    Add a callback to accumulate timing information about the queries running from this data source.
  • setTransactionHandler,
  • setTimingCollector,
  • useHandle,
  • define,
  • close,
  • getStatementLocator,
  • getTransactionHandler,
  • registerColumnMapper

Popular in Java

  • Making http requests using okhttp
  • getExternalFilesDir (Context)
  • notifyDataSetChanged (ArrayAdapter)
  • compareTo (BigDecimal)
    Compares this BigDecimal with the specified BigDecimal. Two BigDecimal objects that are equal in val
  • SocketException (java.net)
    This SocketException may be thrown during socket creation or setting options, and is the superclass
  • URLConnection (java.net)
    The abstract class URLConnection is the superclass of all classes that represent a communications li
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • Dictionary (java.util)
    The Dictionary class is the abstract parent of any class, such as Hashtable, which maps keys to valu
  • LogFactory (org.apache.commons.logging)
    A minimal incarnation of Apache Commons Logging's LogFactory API, providing just the common Log look
  • Table (org.hibernate.mapping)
    A relational table
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now