Search in sources :

Example 1 with SQLite

use of io.requery.sql.platform.SQLite in project requery by requery.

the class JacksonTest method setup.

@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);
}
Also used : ConfigurationBuilder(io.requery.sql.ConfigurationBuilder) Configuration(io.requery.sql.Configuration) WeakEntityCache(io.requery.cache.WeakEntityCache) SQLite(io.requery.sql.platform.SQLite) EntityModel(io.requery.meta.EntityModel) CommonDataSource(javax.sql.CommonDataSource) SchemaModifier(io.requery.sql.SchemaModifier) Before(org.junit.Before)

Example 2 with SQLite

use of io.requery.sql.platform.SQLite in project requery by requery.

the class ParameterizedFunctionalTest method setup.

@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().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);
}
Also used : ConfigurationBuilder(io.requery.sql.ConfigurationBuilder) Configuration(io.requery.sql.Configuration) TableCreationMode(io.requery.sql.TableCreationMode) SQLite(io.requery.sql.platform.SQLite) EntityModel(io.requery.meta.EntityModel) CacheManager(javax.cache.CacheManager) EntityCacheBuilder(io.requery.cache.EntityCacheBuilder) CommonDataSource(javax.sql.CommonDataSource) SQLException(java.sql.SQLException) CachingProvider(javax.cache.spi.CachingProvider) SchemaModifier(io.requery.sql.SchemaModifier) Before(org.junit.Before)

Example 3 with SQLite

use of io.requery.sql.platform.SQLite in project requery by requery.

the class AutoValueModelTest method setup.

@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);
}
Also used : ConfigurationBuilder(io.requery.sql.ConfigurationBuilder) Configuration(io.requery.sql.Configuration) TableCreationMode(io.requery.sql.TableCreationMode) SQLite(io.requery.sql.platform.SQLite) EntityModel(io.requery.meta.EntityModel) EntityCacheBuilder(io.requery.cache.EntityCacheBuilder) CommonDataSource(javax.sql.CommonDataSource) SchemaModifier(io.requery.sql.SchemaModifier) Before(org.junit.Before)

Aggregations

EntityModel (io.requery.meta.EntityModel)3 Configuration (io.requery.sql.Configuration)3 ConfigurationBuilder (io.requery.sql.ConfigurationBuilder)3 SchemaModifier (io.requery.sql.SchemaModifier)3 SQLite (io.requery.sql.platform.SQLite)3 CommonDataSource (javax.sql.CommonDataSource)3 Before (org.junit.Before)3 EntityCacheBuilder (io.requery.cache.EntityCacheBuilder)2 TableCreationMode (io.requery.sql.TableCreationMode)2 WeakEntityCache (io.requery.cache.WeakEntityCache)1 SQLException (java.sql.SQLException)1 CacheManager (javax.cache.CacheManager)1 CachingProvider (javax.cache.spi.CachingProvider)1