Java Code Examples for org.skife.jdbi.v2.Handle#attach()

The following examples show how to use org.skife.jdbi.v2.Handle#attach() . 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: ResultSetMapperFactoryTest.java    From SimpleFlatMapper with MIT License 6 votes vote down vote up
@Test
public void testMapToDbObject() throws Exception {
    DBI dbi = new DBI(DbHelper.getHsqlDataSource());
    dbi.registerMapper(new SfmResultSetMapperFactory());
    Handle handle = dbi.open();
    try {
        DbObject dbObject = handle.createQuery(DbHelper.TEST_DB_OBJECT_QUERY).mapTo(DbObject.class).first();
        DbHelper.assertDbObjectMapping(dbObject);

        SfmBindTest.SfmBindExample attach = handle.attach(SfmBindTest.SfmBindExample.class);
        attach.insert(DbObject.newInstance());
        assertTrue(handle.createQuery("select * from TEST_DB_OBJECT").mapTo(DbObject.class).list().size() > 1);
    } finally {
        handle.close();
    }
}
 
Example 2
Source File: PostgresStorage.java    From cassandra-reaper with Apache License 2.0 5 votes vote down vote up
protected static IStoragePostgreSql getPostgresStorage(Handle handle) {
  handle.registerArgumentFactory(new LongCollectionSqlTypeArgumentFactory());
  handle.registerArgumentFactory(new PostgresArrayArgumentFactory());
  handle.registerArgumentFactory(new RunStateArgumentFactory());
  handle.registerArgumentFactory(new RepairParallelismArgumentFactory());
  handle.registerArgumentFactory(new StateArgumentFactory());
  handle.registerArgumentFactory(new BigIntegerArgumentFactory());
  handle.registerArgumentFactory(new ScheduleStateArgumentFactory());
  handle.registerArgumentFactory(new UuidArgumentFactory());
  handle.registerArgumentFactory(new InstantArgumentFactory());
  return handle.attach(IStoragePostgreSql.class);
}
 
Example 3
Source File: DaoSupplier.java    From presto with Apache License 2.0 4 votes vote down vote up
public T attach(Handle handle)
{
    return handle.attach(type);
}
 
Example 4
Source File: DatabaseProjectStoreManager.java    From digdag with Apache License 2.0 4 votes vote down vote up
public DatabaseProjectControlStore(Handle handle, int siteId)
{
    this.handle = handle;
    this.siteId = siteId;
    this.dao = handle.attach(Dao.class);
}
 
Example 5
Source File: DatabaseSessionStoreManager.java    From digdag with Apache License 2.0 4 votes vote down vote up
public DatabaseSessionAttemptControlStore(Handle handle)
{
    this.handle = handle;
    this.dao = handle.attach(dao(databaseType));
}
 
Example 6
Source File: DatabaseSessionStoreManager.java    From digdag with Apache License 2.0 4 votes vote down vote up
public DatabaseTaskControlStore(Handle handle)
{
    this.handle = handle;
    this.dao = handle.attach(Dao.class);
}
 
Example 7
Source File: DatabaseSessionStoreManager.java    From digdag with Apache License 2.0 4 votes vote down vote up
public DatabaseSessionControlStore(Handle handle, int siteId)
{
    this.handle = handle;
    this.siteId = siteId;
    this.dao = handle.attach(dao(databaseType));
}
 
Example 8
Source File: DatabaseSessionStoreManager.java    From digdag with Apache License 2.0 4 votes vote down vote up
public DatabaseDelayedAttemptControlStore(Handle handle)
{
    this.handle = handle;
    this.dao = handle.attach(dao(databaseType));
}
 
Example 9
Source File: DatabaseScheduleStoreManager.java    From digdag with Apache License 2.0 4 votes vote down vote up
public DatabaseScheduleControlStore(Handle handle)
{
    this.handle = handle;
    this.dao = handle.attach(Dao.class);
}
 
Example 10
Source File: SfmBindTest.java    From SimpleFlatMapper with MIT License 3 votes vote down vote up
@Test
public void testBindDbObject() throws Exception {
    DBI dbi = new DBI(DbHelper.getHsqlDataSource());
    //dbi.registerMapper(new SfmResultSetMapperFactory());

    Handle handle = dbi.open();

    try {
        SfmBindExample attach = handle.attach(SfmBindExample.class);

        DbObject dbObject1 = DbObject.newInstance();
        DbObject dbObject2 = DbObject.newInstance();
        checkObjectNotThere(handle, dbObject1);
        checkObjectNotThere(handle, dbObject2);

        attach.insert(dbObject1);

        checkObjectInserted(attach, handle, dbObject1);

        attach.insert(dbObject2);

        checkObjectInserted(attach, handle, dbObject2);


    } finally {
        handle.close();
    }
}