OracledbDataStorage implements DataStorage<R> { @Override public DataAndId<R> getCurrentData() { try (Connection connection= connectionSupplier.get(); Statement statement = connection.createStatement()){ String sql = "SELECT * FROM FACTORY_CURRENT"; try (ResultSet resultSet =statement.executeQuery(sql)){ if(resultSet.next()){ StoredDataMetadata factoryMetadata = migrationManager.readStoredFactoryMetadata(JdbcUtil.readStringFromBlob(resultSet,"factoryMetadata")); return new DataAndId<>(migrationManager.read(JdbcUtil.readStringFromBlob(resultSet,"factory"),factoryMetadata.dataStorageMetadataDictionary),factoryMetadata.id); } } } catch (SQLException e) { throw new RuntimeException(e); } StoredDataMetadata metadata=new StoredDataMetadata( UUID.randomUUID().toString(), "System", "initial factory", UUID.randomUUID().toString(), null, initialData.internal().createDataStorageMetadataDictionaryFromRoot(),null ); update(initialData, metadata); return new DataAndId<>(initialData, metadata.id); } OracledbDataStorage(Supplier<Connection> connectionSupplier, R initialDataParam,  MigrationManager<R> migrationManager, OracledbDataStorageHistory<R> oracledbDataStorageHistory, OracledbDataStorageFuture<R> oracledbDataStorageFuture, SimpleObjectMapper objectMapper);  OracledbDataStorage(Supplier< Connection > connectionSupplier, R initialDataParam, MigrationManager<R> migrationManager, SimpleObjectMapper objectMapper); @Override R getHistoryData(String id); @Override Collection<StoredDataMetadata> getHistoryDataList(); @Override DataAndId<R> getCurrentData(); @Override void updateCurrentData(DataUpdate<R> update, UpdateSummary changeSummary); @Override void patchAll(DataStoragePatcher consumer); @Override void patchCurrentData(DataStoragePatcher consumer); @Override Collection<ScheduledUpdateMetadata> getFutureDataList(); @Override void deleteFutureData(String id); R getFutureData(String id); @Override void addFutureData(ScheduledUpdate<R> futureFactory);  }
@Test public void test_init_existing_factory() { OracledbDataStorage<ExampleFactoryA> oracledbFactoryStorage = new OracledbDataStorage<>(connectionSupplier, createInitialExampleFactoryA(), createMigrationManager(), ObjectMapperBuilder.build()); String id=oracledbFactoryStorage.getCurrentData().id; OracledbDataStorage<ExampleFactoryA> restored = new OracledbDataStorage<>(connectionSupplier,null, createMigrationManager(), ObjectMapperBuilder.build()); Assertions.assertEquals(id,restored.getCurrentData().id); }