當前位置: 首頁>>代碼示例>>Java>>正文


Java Handle.attach方法代碼示例

本文整理匯總了Java中org.skife.jdbi.v2.Handle.attach方法的典型用法代碼示例。如果您正苦於以下問題:Java Handle.attach方法的具體用法?Java Handle.attach怎麽用?Java Handle.attach使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.skife.jdbi.v2.Handle的用法示例。


在下文中一共展示了Handle.attach方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: migrate

import org.skife.jdbi.v2.Handle; //導入方法依賴的package包/類
@Override
public void migrate(Connection connection) throws Exception {
	TempDataSource ds = new TempDataSource(connection);
	DBI dbi = new DBI(ds);
	dbi.registerContainerFactory(new OptionalContainerFactory());
	Handle handle = dbi.open();
	
	PostgresDataAccessLayer dataAccessLayer = new PostgresDataAccessLayer(
			handle.attach(EntryQueryDAO.class),
			handle.attach(IndexDAO.class),
			handle.attach(IndexQueryDAO.class),
			handle.attach(EntryDAO.class),
			handle.attach(EntryItemDAO.class),
			handle.attach(ItemQueryDAO.class),
			handle.attach(ItemDAO.class),
			connection.getSchema(),
			new IndexDriver(),
			ImmutableMap.of(EntryType.user, Arrays.asList(new LatestByKeyIndexFunction(IndexNames.RECORD))));

	IndexDriver indexDriver = new IndexDriver();

	Map<String, Entry> entries = new HashMap<>();
	int currentIndexEntryNumber = 0;

	dataAccessLayer.getEntryIterator().forEachRemaining(entry -> {
		indexDriver.indexEntry(dataAccessLayer, entry, new LatestByKeyIndexFunction(IndexNames.RECORD), entries, currentIndexEntryNumber);
	});
	
	dataAccessLayer.checkpoint();
}
 
開發者ID:openregister,項目名稱:openregister-java,代碼行數:31,代碼來源:R__11_Migrate_current_keys_to_index.java

示例2: getTransactionalDataAccessLayer

import org.skife.jdbi.v2.Handle; //導入方法依賴的package包/類
private PostgresDataAccessLayer getTransactionalDataAccessLayer(Handle handle) {
    return new PostgresDataAccessLayer(
            handle.attach(EntryQueryDAO.class),
            handle.attach(IndexDAO.class),
            handle.attach(IndexQueryDAO.class),
            handle.attach(EntryDAO.class),
            handle.attach(EntryItemDAO.class),
            handle.attach(ItemQueryDAO.class),
            handle.attach(ItemDAO.class),
            schema,
            new IndexDriver(),
            getIndexFunctions());
}
 
開發者ID:openregister,項目名稱:openregister-java,代碼行數:14,代碼來源:RegisterContext.java

示例3: setUp

import org.skife.jdbi.v2.Handle; //導入方法依賴的package包/類
@BeforeClass
public static void setUp() throws Exception {
    Handle handle = register.handleFor(testRegister);
    testItemDAO = handle.attach(TestItemCommandDAO.class);
    testEntryDAO = handle.attach(TestEntryDAO.class);
    testRecordDAO = handle.attach(IndexQueryDAO.class);
}
 
開發者ID:openregister,項目名稱:openregister-java,代碼行數:8,代碼來源:LoadSerializedFunctionalTest.java

示例4: setUpClass

import org.skife.jdbi.v2.Handle; //導入方法依賴的package包/類
@BeforeClass
public static void setUpClass() throws Exception {
    Handle handle = register.handleFor(TestRegister.register);
    testRecordDAO = handle.attach(IndexQueryDAO.class);
    testEntryDAO = handle.attach(TestEntryDAO.class);
    testItemDAO = handle.attach(TestItemCommandDAO.class);
    schema = TestRegister.register.getSchema();
}
 
開發者ID:openregister,項目名稱:openregister-java,代碼行數:9,代碼來源:DataUploadFunctionalTest.java

示例5: getTransactionalDataAccessLayer

import org.skife.jdbi.v2.Handle; //導入方法依賴的package包/類
private PostgresDataAccessLayer getTransactionalDataAccessLayer(Handle handle) {
    return new PostgresDataAccessLayer(
            handle.attach(EntryQueryDAO.class),
            handle.attach(IndexDAO.class),
            handle.attach(IndexQueryDAO.class),
            handle.attach(EntryDAO.class),
            handle.attach(EntryItemDAO.class),
            handle.attach(ItemQueryDAO.class),
            handle.attach(ItemDAO.class),
            "address",
            indexDriver,
            ImmutableMap.of(EntryType.user, Arrays.asList(new LatestByKeyIndexFunction(IndexNames.RECORD)), EntryType.system, Arrays.asList(new LatestByKeyIndexFunction(IndexNames.METADATA))));
}
 
開發者ID:openregister,項目名稱:openregister-java,代碼行數:14,代碼來源:PostgresRegisterTransactionalFunctionalTest.java

示例6: getPostgresStorage

import org.skife.jdbi.v2.Handle; //導入方法依賴的package包/類
private 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());
  return handle.attach(IStoragePostgreSql.class);
}
 
開發者ID:thelastpickle,項目名稱:cassandra-reaper,代碼行數:12,代碼來源:PostgresStorage.java

示例7: migrate

import org.skife.jdbi.v2.Handle; //導入方法依賴的package包/類
@Override
public void migrate(Connection connection) throws Exception {
	InputStream registersRecordsInputStream = null;
	InputStream fieldsRecordsInputStream = null;
	
	try {
		TempDataSource ds = new TempDataSource(connection);
		DBI dbi = new DBI(ds);
		Handle handle = dbi.open();

		EntryQueryDAO entryQueryDAO = handle.attach(EntryQueryDAO.class);
		if (entryQueryDAO.getTotalEntries(connection.getSchema()) > 0) {
			List<Record> records = new ArrayList<>();

			String registerName = flywayConfiguration.getPlaceholders().get("registerName");
			Record nameRecord = singleRecord("name", registerName, 1);
			records.add(nameRecord);

			String custodianName = flywayConfiguration.getPlaceholders().get("custodianName");
			if (!custodianName.isEmpty()) {
				Record custodianRecord = singleRecord("custodian", custodianName, 2);
				records.add(custodianRecord);
			}

			registersRecordsInputStream = getInputStream(flywayConfiguration.getPlaceholders().get("registersYamlUrl"));

			Record registerRecord = parseYamlToRecords(Arrays.asList(registerName), registersRecordsInputStream, "register").get(0);
			Item registerItem = registerRecord.getItems().get(0);
			List<String> fieldNames = getFieldNames(registerItem);

			fieldsRecordsInputStream = getInputStream(flywayConfiguration.getPlaceholders().get("fieldsYamlUrl"));
			records.addAll(parseYamlToRecords(fieldNames, fieldsRecordsInputStream, "field"));

			records.add(registerRecord);

			AtomicInteger entryNumber = new AtomicInteger(1);

			List<Record> allRecordsFixedEntryNumbers = records.stream()
					.map(r -> copyWithEntryNumber(r, entryNumber.getAndIncrement())).collect(toList());

			writeRecords(connection, handle, allRecordsFixedEntryNumbers);
		}
	} finally {
		if (registersRecordsInputStream != null) {
			registersRecordsInputStream.close();
		}
		if (fieldsRecordsInputStream != null) {
			fieldsRecordsInputStream.close();
		}
	}
}
 
開發者ID:openregister,項目名稱:openregister-java,代碼行數:52,代碼來源:R__10_Insert_register_metadata.java


注:本文中的org.skife.jdbi.v2.Handle.attach方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。