use of io.requery.sql.SchemaModifier 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);
}
use of io.requery.sql.SchemaModifier in project requery by requery.
the class RxTest 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 = RxSupport.toReactiveStore(new EntityDataStore<Persistable>(configuration));
}
use of io.requery.sql.SchemaModifier in project requery by requery.
the class StatelessTest method setup.
@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);
}
use of io.requery.sql.SchemaModifier in project requery by requery.
the class ReactorTest 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 = new ReactorEntityStore<>(new EntityDataStore<Persistable>(configuration));
}
use of io.requery.sql.SchemaModifier 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;
}
});
}
Aggregations