Search in sources :

Example 6 with EntityModel

use of io.requery.meta.EntityModel in project requery by requery.

the class TimeConversionsTest method setup.

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

Example 7 with EntityModel

use of io.requery.meta.EntityModel in project requery by requery.

the class BenchmarkTest method setup.

@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;
        }
    });
}
Also used : EntityModel(io.requery.meta.EntityModel) Person(io.requery.test.model.Person) SQLException(java.sql.SQLException) RunnerException(org.openjdk.jmh.runner.RunnerException) MalformedURLException(java.net.MalformedURLException) NoBenchmarksException(org.openjdk.jmh.runner.NoBenchmarksException) SchemaModifier(io.requery.sql.SchemaModifier) Setup(org.openjdk.jmh.annotations.Setup)

Example 8 with EntityModel

use of io.requery.meta.EntityModel in project requery by requery.

the class JPAModelTest method setup.

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

Example 9 with EntityModel

use of io.requery.meta.EntityModel in project FastHub by k0shk0sh.

the class App method getDataStore.

public ReactiveEntityStore<Persistable> getDataStore() {
    if (dataStore == null) {
        EntityModel model = Models.DEFAULT;
        DatabaseSource source = new DatabaseSource(this, model, "FastHub-DB", 18);
        Configuration configuration = source.getConfiguration();
        if (BuildConfig.DEBUG) {
            source.setTableCreationMode(TableCreationMode.CREATE_NOT_EXISTS);
        }
        dataStore = ReactiveSupport.toReactiveStore(new EntityDataStore<Persistable>(configuration));
    }
    return dataStore;
}
Also used : DatabaseSource(io.requery.android.sqlite.DatabaseSource) Configuration(io.requery.sql.Configuration) EntityDataStore(io.requery.sql.EntityDataStore) EntityModel(io.requery.meta.EntityModel)

Example 10 with EntityModel

use of io.requery.meta.EntityModel in project requery by requery.

the class ReactiveTest method setup.

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

Aggregations

EntityModel (io.requery.meta.EntityModel)14 Configuration (io.requery.sql.Configuration)13 SchemaModifier (io.requery.sql.SchemaModifier)13 ConfigurationBuilder (io.requery.sql.ConfigurationBuilder)12 CommonDataSource (javax.sql.CommonDataSource)12 Before (org.junit.Before)12 EntityCacheBuilder (io.requery.cache.EntityCacheBuilder)6 EntityDataStore (io.requery.sql.EntityDataStore)5 Platform (io.requery.sql.Platform)5 HSQL (io.requery.sql.platform.HSQL)5 CacheManager (javax.cache.CacheManager)5 CachingProvider (javax.cache.spi.CachingProvider)5 EmptyEntityCache (io.requery.cache.EmptyEntityCache)3 TableCreationMode (io.requery.sql.TableCreationMode)3 SQLite (io.requery.sql.platform.SQLite)3 SQLException (java.sql.SQLException)3 TransactionIsolation (io.requery.TransactionIsolation)1 TransactionListener (io.requery.TransactionListener)1 DatabaseSource (io.requery.android.sqlite.DatabaseSource)1 WeakEntityCache (io.requery.cache.WeakEntityCache)1