use of io.requery.sql.Configuration 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);
}
use of io.requery.sql.Configuration in project requery by requery.
the class PeopleApplication method getData.
/**
* @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;
}
use of io.requery.sql.Configuration 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);
}
use of io.requery.sql.Configuration 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);
}
use of io.requery.sql.Configuration 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);
}
Aggregations