io.requery.sql.Configuration Java Examples

The following examples show how to use io.requery.sql.Configuration. 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: TimeConversionsTest.java    From requery with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #2
Source File: JPAModelTest.java    From requery with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #3
Source File: UpsertTest.java    From requery with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #4
Source File: ReactorTest.java    From requery with Apache License 2.0 6 votes vote down vote up
@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));
}
 
Example #5
Source File: StatelessTest.java    From requery with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #6
Source File: AutoValueModelTest.java    From requery with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #7
Source File: ReactiveTest.java    From requery with Apache License 2.0 6 votes vote down vote up
@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));
}
 
Example #8
Source File: SchemaModifierTest.java    From requery with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #9
Source File: ModuleDatabase.java    From AndroidStarterAlt with Apache License 2.0 5 votes vote down vote up
@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;
    }
 
Example #10
Source File: MockModuleDatabase.java    From AndroidStarterAlt with Apache License 2.0 5 votes vote down vote up
@Provides
@Singleton
@Override
public SingleEntityStore<Persistable> provideDataStore(@NonNull final Context poContext) {
    final DatabaseSource loSource = new DatabaseSource(poContext, Models.DEFAULT, "mock_android_starter_alt.sqlite", 1);
    final Configuration loConfiguration = loSource.getConfiguration();
    final SingleEntityStore<Persistable> loDataStore = RxSupport.toReactiveStore(new EntityDataStore<>(loConfiguration));
    return loDataStore;
}
 
Example #11
Source File: PretixDroid.java    From pretixdroid with GNU General Public License v3.0 5 votes vote down vote up
public BlockingEntityStore<Persistable> getData() {
    if (dataStore == null) {
        // override onUpgrade to handle migrating to a new version
        DatabaseSource source = new DatabaseSource(this, Models.DEFAULT, 6);
        Configuration configuration = source.getConfiguration();
        dataStore = new EntityDataStore<Persistable>(configuration);
    }
    return dataStore;
}
 
Example #12
Source File: PeopleApplication.java    From requery with Apache License 2.0 5 votes vote down vote up
/**
 * @return {@link EntityDataStore} single instance for the application.
 * <p/>
 * Note if you're using Dagger you can make this part of your application level module returning
 * {@code @Provides @Singleton}.
 */
ReactiveEntityStore<Persistable> getData() {
    if (dataStore == null) {
        // override onUpgrade to handle migrating to a new version
        DatabaseSource source = new DatabaseSource(this, 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;
}
 
Example #13
Source File: JacksonTest.java    From requery with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() throws SQLException {
    CommonDataSource dataSource = DatabaseType.getDataSource(new SQLite());
    EntityModel model = Models.MODEL3;
    Configuration configuration = new ConfigurationBuilder(dataSource, model)
        .useDefaultLogging()
        .setEntityCache(new WeakEntityCache())
        .setWriteExecutor(Executors.newSingleThreadExecutor())
        .build();

    SchemaModifier tables = new SchemaModifier(configuration);
    tables.createTables(TableCreationMode.DROP_CREATE);
    data = new EntityDataStore<>(configuration);
}
 
Example #14
Source File: ParameterizedFunctionalTest.java    From requery with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() throws SQLException {
    CommonDataSource dataSource = DatabaseType.getDataSource(platform);
    EntityModel model = Models.DEFAULT;

    CachingProvider provider = Caching.getCachingProvider();
    CacheManager cacheManager = provider.getCacheManager();
    Configuration configuration = new ConfigurationBuilder(dataSource, model)
        .useDefaultLogging()
        // work around bug reusing prepared statements in xerial sqlite
        .setStatementCacheSize(platform instanceof SQLite ? 0 : 10)
        .setBatchUpdateSize(50)
        .setEntityCache(new EntityCacheBuilder(model)
            .useReferenceCache(true)
            .useSerializableCache(true)
            .useCacheManager(cacheManager)
            .build())
        .build();
    data = new EntityDataStore<>(configuration);
    SchemaModifier tables = new SchemaModifier(configuration);
    try {
        tables.dropTables();
    } catch (Exception e) {
        // expected if 'drop if exists' not supported (so ignore in that case)
        if (!platform.supportsIfExists()) {
            throw e;
        }
    }
    TableCreationMode mode = TableCreationMode.CREATE;
    System.out.println(tables.createTablesString(mode));
    tables.createTables(mode);
}
 
Example #15
Source File: PerfTestRequery.java    From android-database-performance with Apache License 2.0 5 votes vote down vote up
private void setupDatabase() {
    DatabaseSource source = new DatabaseSource(getTargetContext(), Models.DEFAULT,
            DATABASE_VERSION);
    Configuration configuration = new ConfigurationBuilder(source,
            Models.DEFAULT).setEntityCache(new EmptyEntityCache()).build();
    database = new EntityDataStore<>(configuration).toBlocking();
}
 
Example #16
Source File: DatabaseProvider.java    From requery with Apache License 2.0 2 votes vote down vote up
/**
 * @return {@link Configuration} used by the provider
 */
Configuration getConfiguration();