@Override public String name() { return Database.this.getName(); }
/** * Converts the given database to a Scala database * @return the database for scala API. * @deprecated As of release 2.6.0. Use {@link #asScala()} */ @Deprecated public default play.api.db.Database toScala() { return asScala(); }
@Override public DataSource dataSource() { return Database.this.getDataSource(); }
public <A> A withTransaction( final scala.Function1<Connection, A> block) { return Database.this.withTransaction(block::apply); }
@Override public Connection getConnection() { return Database.this.getConnection(); }
@Override public <A> A withConnection( final scala.Function1<Connection, A> block) { return Database.this.withConnection(block::apply); }
@Override public void shutdown() { Database.this.shutdown(); }
@Override public String url() { return Database.this.getUrl(); }
public <A> A withTransaction(play.api.db.TransactionIsolationLevel isolationLevel, final scala.Function1<Connection, A> block) { return Database.this.withTransaction(isolationLevel.asJava(), block::apply); } };
@Override public Connection getConnection(boolean autocommit) { return Database.this.getConnection(autocommit); }
@Override public <A> A withConnection(boolean autocommit, final scala.Function1<Connection, A> block) { return Database.this.withConnection(autocommit, block::apply); }
@Inject public DefaultDBApi(play.api.db.DBApi dbApi) { this.dbApi = dbApi; ImmutableList.Builder<Database> databases = new ImmutableList.Builder<Database>(); ImmutableMap.Builder<String, Database> databaseByName = new ImmutableMap.Builder<String, Database>(); for (play.api.db.Database db : Scala.asJava(dbApi.databases())) { Database database = new DefaultDatabase(db); databases.add(database); databaseByName.put(database.getName(), database); } this.databases = databases.build(); this.databaseByName = databaseByName.build(); }
/** * Apply evolutions for the given database. * * @param database The database to apply the evolutions to. * @param reader The reader to read the evolutions. * @param autocommit Whether autocommit should be used. * @param schema The schema where all the play evolution tables are saved in */ public static void applyEvolutions(Database database, play.api.db.evolutions.EvolutionsReader reader, boolean autocommit, String schema) { DatabaseEvolutions evolutions = new DatabaseEvolutions(database.asScala(), schema); evolutions.evolve(evolutions.scripts(reader), autocommit); }
private void setServerConfigDataSource(String key, ServerConfig serverConfig) { try { serverConfig.setDataSource(new WrappingDatasource(dbApi.getDatabase(key).getDataSource())); } catch(Exception e) { throw new ConfigException.BadValue( "ebean." + key, e.getMessage(), e ); } }
@Inject public DefaultDBApi(play.api.db.DBApi dbApi) { this.dbApi = dbApi; ImmutableList.Builder<Database> databases = new ImmutableList.Builder<Database>(); ImmutableMap.Builder<String, Database> databaseByName = new ImmutableMap.Builder<String, Database>(); for (play.api.db.Database db : Scala.asJava(dbApi.databases())) { Database database = new DefaultDatabase(db); databases.add(database); databaseByName.put(database.getName(), database); } this.databases = databases.build(); this.databaseByName = databaseByName.build(); }
/** * Cleanup evolutions for the given database. * * This will run the down scripts for all the applied evolutions. * * @param database The database to apply the evolutions to. * @param autocommit Whether autocommit should be used. * @param schema The schema where all the play evolution tables are saved in */ public static void cleanupEvolutions(Database database, boolean autocommit, String schema) { DatabaseEvolutions evolutions = new DatabaseEvolutions(database.asScala(), schema); evolutions.evolve(evolutions.resetScripts(), autocommit); }