本文整理汇总了Java中io.requery.sql.EntityDataStore类的典型用法代码示例。如果您正苦于以下问题:Java EntityDataStore类的具体用法?Java EntityDataStore怎么用?Java EntityDataStore使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EntityDataStore类属于io.requery.sql包,在下文中一共展示了EntityDataStore类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: provideDatabaseSource
import io.requery.sql.EntityDataStore; //导入依赖的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: setup
import io.requery.sql.EntityDataStore; //导入依赖的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);
}
示例3: setup
import io.requery.sql.EntityDataStore; //导入依赖的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);
}
示例4: setup
import io.requery.sql.EntityDataStore; //导入依赖的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);
}
示例5: setup
import io.requery.sql.EntityDataStore; //导入依赖的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));
}
示例6: setup
import io.requery.sql.EntityDataStore; //导入依赖的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);
}
示例7: setup
import io.requery.sql.EntityDataStore; //导入依赖的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);
}
示例8: setup
import io.requery.sql.EntityDataStore; //导入依赖的package包/类
@Setup
public void setup() {
EntityModel model = Models.DEFAULT;
dataSource = (DataSource) DatabaseType.getDataSource(platform);
data = new EntityDataStore<>(dataSource, model);
new SchemaModifier(dataSource, model).createTables(TableCreationMode.DROP_CREATE);
final int count = 10000;
data.runInTransaction(new Callable<Object>() {
@Override
public Object call() throws Exception {
for (int i = 0; i < count; i++) {
Person person = FunctionalTest.randomPerson();
data.insert(person);
}
return null;
}
});
}
示例9: setup
import io.requery.sql.EntityDataStore; //导入依赖的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.EntityDataStore; //导入依赖的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: reactiveStore
import io.requery.sql.EntityDataStore; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void reactiveStore() 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(ReactiveEntityStore.class, "DEFAULT"))
.expect(onStart)
.expect(configurationBuilder)
.expect(eds)
.expect(unit -> {
unit.mockStatic(ReactiveSupport.class);
expect(ReactiveSupport.toReactiveStore(unit.get(EntityDataStore.class)))
.andReturn(null);
})
.run(unit -> {
Requery.reactive(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));
});
}
示例12: reactorStore
import io.requery.sql.EntityDataStore; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void reactorStore() 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(ReactorEntityStore.class, "DEFAULT"))
.expect(onStart)
.expect(configurationBuilder)
.expect(eds)
.expect(unit -> {
unit.constructor(ReactorEntityStore.class)
.build(unit.get(EntityDataStore.class));
})
.run(unit -> {
Requery.reactor(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: completableEntityStore
import io.requery.sql.EntityDataStore; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void completableEntityStore() 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(CompletionStageEntityStore.class, "DEFAULT"))
.expect(onStart)
.expect(configurationBuilder)
.expect(eds)
.expect(unit -> {
unit.constructor(CompletableEntityStore.class)
.build(unit.get(EntityDataStore.class));
})
.run(unit -> {
Requery.completionStage(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));
});
}
示例14: getData
import io.requery.sql.EntityDataStore; //导入依赖的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;
}
示例15: getDataStore
import io.requery.sql.EntityDataStore; //导入依赖的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);
}