本文整理汇总了Java中io.requery.sql.Configuration类的典型用法代码示例。如果您正苦于以下问题:Java Configuration类的具体用法?Java Configuration怎么用?Java Configuration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Configuration类属于io.requery.sql包,在下文中一共展示了Configuration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: provideDatabaseSource
import io.requery.sql.Configuration; //导入依赖的package包/类
@Singleton
@Provides
public EntityDataStore<Persistable> provideDatabaseSource() {
Observable.<Void>just(null).observeOn(Schedulers.io()).subscribe(new Action1<Void>() {
@Override
public void call(Void aVoid) {
raw2data(app, DB_NAME, R.raw.books);
}
});
DatabaseSource source = new DatabaseSource(app, Models.DEFAULT, DB_NAME, DB_VERSION);
source.setLoggingEnabled(BuildConfig.DEBUG);
Configuration configuration = source.getConfiguration();
return new EntityDataStore<>(configuration);
}
示例2: getConfiguration
import io.requery.sql.Configuration; //导入依赖的package包/类
@Override
public Configuration getConfiguration() {
if (mapping == null) {
mapping = onCreateMapping(platform);
}
if (mapping == null) {
throw new IllegalStateException();
}
if (configuration == null) {
ConfigurationBuilder builder = new ConfigurationBuilder(this, model)
.setMapping(mapping)
.setPlatform(platform)
.setBatchUpdateSize(1000);
onConfigure(builder);
configuration = builder.build();
}
return configuration;
}
示例3: setup
import io.requery.sql.Configuration; //导入依赖的package包/类
@Before
public void setup() throws SQLException {
Platform platform = new HSQL();
CommonDataSource dataSource = DatabaseType.getDataSource(platform);
EntityModel model = Models.MODEL2;
Configuration configuration = new ConfigurationBuilder(dataSource, model)
.useDefaultLogging()
.setEntityCache(new EmptyEntityCache())
.setWriteExecutor(Executors.newSingleThreadExecutor())
.build();
SchemaModifier tables = new SchemaModifier(configuration);
tables.createTables(TableCreationMode.DROP_CREATE);
data = new EntityDataStore<>(configuration);
}
示例4: setup
import io.requery.sql.Configuration; //导入依赖的package包/类
@Before
public void setup() throws SQLException {
CommonDataSource dataSource = DatabaseType.getDataSource(new H2());
EntityModel model = Models.JPA;
CachingProvider provider = Caching.getCachingProvider();
CacheManager cacheManager = provider.getCacheManager();
Configuration configuration = new ConfigurationBuilder(dataSource, model)
.useDefaultLogging()
.setEntityCache(new EntityCacheBuilder(model)
.useReferenceCache(true)
.useSerializableCache(true)
.useCacheManager(cacheManager)
.build())
.build();
data = new EntityDataStore<>(configuration);
SchemaModifier tables = new SchemaModifier(configuration);
tables.dropTables();
TableCreationMode mode = TableCreationMode.CREATE;
System.out.println(tables.createTablesString(mode));
tables.createTables(mode);
}
示例5: setup
import io.requery.sql.Configuration; //导入依赖的package包/类
@Before
public void setup() throws SQLException {
CommonDataSource dataSource = DatabaseType.getDataSource(platform);
EntityModel model = Models.MODEL3;
Configuration configuration = new ConfigurationBuilder(dataSource, model)
.useDefaultLogging()
.setEntityCache(new EmptyEntityCache())
.setWriteExecutor(Executors.newSingleThreadExecutor())
.build();
SchemaModifier tables = new SchemaModifier(configuration);
tables.createTables(TableCreationMode.DROP_CREATE);
System.out.println(tables.createTablesString(TableCreationMode.DROP_CREATE));
data = new EntityDataStore<>(configuration);
}
示例6: setup
import io.requery.sql.Configuration; //导入依赖的package包/类
@Before
public void setup() throws SQLException {
Platform platform = new HSQL();
CommonDataSource dataSource = DatabaseType.getDataSource(platform);
EntityModel model = io.requery.test.model.Models.DEFAULT;
CachingProvider provider = Caching.getCachingProvider();
CacheManager cacheManager = provider.getCacheManager();
Configuration configuration = new ConfigurationBuilder(dataSource, model)
.useDefaultLogging()
.setWriteExecutor(Executors.newSingleThreadExecutor())
.setEntityCache(new EntityCacheBuilder(model)
.useReferenceCache(true)
.useSerializableCache(true)
.useCacheManager(cacheManager)
.build())
.build();
SchemaModifier tables = new SchemaModifier(configuration);
tables.createTables(TableCreationMode.DROP_CREATE);
data = new ReactorEntityStore<>(new EntityDataStore<Persistable>(configuration));
}
示例7: setup
import io.requery.sql.Configuration; //导入依赖的package包/类
@Before
public void setup() throws SQLException {
CommonDataSource dataSource = DatabaseType.getDataSource(platform);
EntityModel model = Models.STATELESS;
Configuration configuration = new ConfigurationBuilder(dataSource, model)
.useDefaultLogging()
.setEntityCache(new EmptyEntityCache())
.setWriteExecutor(Executors.newSingleThreadExecutor())
.build();
SchemaModifier tables = new SchemaModifier(configuration);
tables.createTables(TableCreationMode.DROP_CREATE);
System.out.println(tables.createTablesString(TableCreationMode.DROP_CREATE));
data = new EntityDataStore<>(configuration);
}
示例8: setup
import io.requery.sql.Configuration; //导入依赖的package包/类
@Before
public void setup() throws SQLException {
CommonDataSource dataSource = DatabaseType.getDataSource(new SQLite());
EntityModel model = Models.AUTOVALUE;
Configuration configuration = new ConfigurationBuilder(dataSource, model)
.useDefaultLogging()
.setEntityCache(new EntityCacheBuilder(model)
.useReferenceCache(true)
.build())
.build();
data = new EntityDataStore<>(configuration);
SchemaModifier tables = new SchemaModifier(configuration);
tables.dropTables();
TableCreationMode mode = TableCreationMode.CREATE_NOT_EXISTS;
System.out.println(tables.createTablesString(mode));
tables.createTables(mode);
}
示例9: setup
import io.requery.sql.Configuration; //导入依赖的package包/类
@Before
public void setup() throws SQLException {
Platform platform = new HSQL();
CommonDataSource dataSource = DatabaseType.getDataSource(platform);
EntityModel model = io.requery.test.model.Models.DEFAULT;
CachingProvider provider = Caching.getCachingProvider();
CacheManager cacheManager = provider.getCacheManager();
Configuration configuration = new ConfigurationBuilder(dataSource, model)
.useDefaultLogging()
.setWriteExecutor(Executors.newSingleThreadExecutor())
.setEntityCache(new EntityCacheBuilder(model)
.useReferenceCache(true)
.useSerializableCache(true)
.useCacheManager(cacheManager)
.build())
.build();
SchemaModifier tables = new SchemaModifier(configuration);
tables.createTables(TableCreationMode.DROP_CREATE);
data = ReactiveSupport.toReactiveStore(new EntityDataStore<Persistable>(configuration));
}
示例10: setup
import io.requery.sql.Configuration; //导入依赖的package包/类
@Before
public void setup() throws SQLException {
Platform platform = new HSQL();
CommonDataSource dataSource = DatabaseType.getDataSource(platform);
EntityModel model = io.requery.test.model.Models.DEFAULT;
CachingProvider provider = Caching.getCachingProvider();
CacheManager cacheManager = provider.getCacheManager();
Configuration configuration = new ConfigurationBuilder(dataSource, model)
.useDefaultLogging()
.setWriteExecutor(Executors.newSingleThreadExecutor())
.setEntityCache(new EntityCacheBuilder(model)
.useReferenceCache(true)
.useSerializableCache(true)
.useCacheManager(cacheManager)
.build())
.build();
SchemaModifier tables = new SchemaModifier(configuration);
tables.createTables(TableCreationMode.DROP_CREATE);
data = RxSupport.toReactiveStore(new EntityDataStore<Persistable>(configuration));
}
示例11: setup
import io.requery.sql.Configuration; //导入依赖的package包/类
@Before
public void setup() throws SQLException {
CommonDataSource dataSource = DatabaseType.getDataSource(platform);
EntityModel model = io.requery.test.model.Models.DEFAULT;
Configuration configuration = new ConfigurationBuilder(dataSource, model)
.useDefaultLogging()
.setStatementCacheSize(10)
.setBatchUpdateSize(50)
.setWriteExecutor(Executors.newSingleThreadExecutor())
.build();
schemaModifier = new SchemaModifier(configuration);
try {
schemaModifier.dropTables();
} catch (Exception e) {
// expected if 'drop if exists' not supported (so ignore in that case)
if (!platform.supportsIfExists()) {
throw e;
}
}
schemaModifier.createTables(TableCreationMode.CREATE);
}
示例12: kotlinStore
import io.requery.sql.Configuration; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void kotlinStore() throws Exception {
new MockUnit(Env.class, Config.class, Binder.class, EntityModel.class, Registry.class)
.expect(newDataSource(true))
.expect(keys)
.expect(zeroModels)
.expect(noSchema)
.expect(store(KotlinEntityDataStore.class, "DEFAULT"))
.expect(onStart)
.expect(configurationBuilder)
.expect(unit -> {
unit.constructor(KotlinEntityDataStore.class)
.build(unit.get(Configuration.class));
})
.run(unit -> {
Requery.kotlin(unit.get(EntityModel.class))
.configure(unit.get(Env.class), unit.get(Config.class), unit.get(Binder.class));
}, unit -> {
unit.captured(Throwing.Consumer.class).iterator().next()
.accept(unit.get(Registry.class));
});
}
示例13: getData
import io.requery.sql.Configuration; //导入依赖的package包/类
@NonNull
public ReactiveEntityStore<Persistable> getData() throws RuntimeException {
if (dataStore == null) {
// override onUpgrade to handle migrating to a new version
DatabaseSource source = new DatabaseSource(getReflectedContext(), Models.DEFAULT, 1);
if (BuildConfig.DEBUG) {
// use this in development mode to drop and recreate the tables on every upgrade
source.setTableCreationMode(TableCreationMode.DROP_CREATE);
}
Configuration configuration = source.getConfiguration();
dataStore = ReactiveSupport.toReactiveStore(
new EntityDataStore<Persistable>(configuration));
}
return dataStore;
}
示例14: getDataStore
import io.requery.sql.Configuration; //导入依赖的package包/类
public static EntityDataStore<Persistable> getDataStore(DatabaseSource source) {
Configuration configuration = new ConfigurationBuilder(source, Models.DEFAULT)
.setMapping(new MainMapping())
.setStatementCacheSize(100)
.setEntityCache(new EntityCacheBuilder(Models.DEFAULT)
.useReferenceCache(true)
.build())
.build();
return new EntityDataStore<>(configuration);
}
示例15: provideDataStore
import io.requery.sql.Configuration; //导入依赖的package包/类
@Provides
@Singleton
public SingleEntityStore<Persistable> provideDataStore(@NonNull final Context poContext) {
// final DatabaseProvider<SQLiteDatabase> loSource = new DatabaseSource(poContext, Models.DEFAULT, "android_starter_alt.sqlite", 1);
final DatabaseProvider<SQLiteDatabase> loSource = new SqlCipherDatabaseSource(poContext, Models.DEFAULT, "android_start_alt_requery_sqlcipher.sqlite", "android_starter_alt", 1);
final Configuration loConfiguration = loSource.getConfiguration();
final SingleEntityStore<Persistable> loDataStore = RxSupport.toReactiveStore(new EntityDataStore<>(loConfiguration));
return loDataStore;
}