Java Code Examples for com.avaje.ebean.config.ServerConfig#setDefaultServer()

The following examples show how to use com.avaje.ebean.config.ServerConfig#setDefaultServer() . 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: InMemoryEbeanServer.java    From dropwizard-experiment with MIT License 6 votes vote down vote up
public InMemoryEbeanServer() {
    // Create in-memory database configuration.
    DataSourceConfig dbConfig = new DataSourceConfig();
    dbConfig.setUsername("sa");
    dbConfig.setPassword("");
    dbConfig.setUrl("jdbc:h2:mem:tests2;DB_CLOSE_DELAY=-1");
    dbConfig.setDriver("org.h2.Driver");

    ServerConfig config = new ServerConfig();
    config.setName("h2");
    config.setDataSourceConfig(dbConfig);
    config.setDefaultServer(true);

    for (Class<?> entity : EbeanEntities.getEntities()) {
        config.addClass(entity);
    }

    config.setDdlGenerate(true);
    config.setDdlRun(true);

    server = EbeanServerFactory.create(config);
    ddl = ((SpiEbeanServer) server).getDdlGenerator();
}
 
Example 2
Source File: DbTestsApplication.java    From java-persistence-frameworks-comparison with MIT License 5 votes vote down vote up
@SuppressWarnings("SpringJavaAutowiringInspection")
@Bean
public ServerConfig ebeanServerConfig(DataSource dataSource) {
    ServerConfig config = new ServerConfig();
    config.setName("ebeanServer");
    config.setDefaultServer(true);
    config.setDataSource(dataSource);
    config.addPackage("com.clevergang.dbtests.repository.impl.ebean.entities");
    config.setExternalTransactionManager(new SpringAwareJdbcTransactionManager());
    config.setAutoCommitMode(false);
    config.setExpressionNativeIlike(true);

    return config;
}
 
Example 3
Source File: EbeanConfigUtils.java    From dropwizard-experiment with MIT License 5 votes vote down vote up
public static ServerConfig createServerConfig(DataSourceFactory dbConfig) {
    ServerConfig config = new ServerConfig();
    config.setName("main");
    config.setDataSourceConfig(createDataSourceConfig(dbConfig));
    config.setDefaultServer(true);

    EbeanEntities.getEntities().forEach(config::addClass);

    return config;
}