diff --git a/docs/guides/AGENTS.md b/docs/guides/AGENTS.md
index 23927fe405..d926c678e7 100644
--- a/docs/guides/AGENTS.md
+++ b/docs/guides/AGENTS.md
@@ -11,6 +11,7 @@ Step-by-step guides for common Ebean tasks (Maven setup, database config, query
Key guides (fetch and follow when performing the relevant task):
- Maven POM setup: https://raw.githubusercontent.com/ebean-orm/ebean/HEAD/docs/guides/add-ebean-postgres-maven-pom.md
- Database configuration: https://raw.githubusercontent.com/ebean-orm/ebean/HEAD/docs/guides/add-ebean-postgres-database-config.md
+- Migrate to `Database.builder()`: https://raw.githubusercontent.com/ebean-orm/ebean/HEAD/docs/guides/migrating-to-database-builder.md
- Write queries with query beans: https://raw.githubusercontent.com/ebean-orm/ebean/HEAD/docs/guides/writing-ebean-query-beans.md
- Persisting and transactions: https://raw.githubusercontent.com/ebean-orm/ebean/HEAD/docs/guides/persisting-and-transactions-with-ebean.md
- Test container setup: https://raw.githubusercontent.com/ebean-orm/ebean/HEAD/docs/guides/add-ebean-postgres-test-container.md
diff --git a/docs/guides/README.md b/docs/guides/README.md
index cfcefb86f8..183ed77df9 100644
--- a/docs/guides/README.md
+++ b/docs/guides/README.md
@@ -18,6 +18,12 @@ existing Maven project. Complete the steps in order.
| 2 | [Test container setup](add-ebean-postgres-test-container.md) | Start a PostgreSQL (or PostGIS) Docker container for tests using `@TestScope @Factory` with Avaje Inject; verify the test database works with `mvn verify` before adding production configuration |
| 3 | [Database configuration](add-ebean-postgres-database-config.md) | Configure the production Ebean `Database` bean using `DataSourceBuilder` and `DatabaseBuilder` with Avaje Inject |
+## Migration & upgrades
+
+| Guide | Description |
+|-------|-------------|
+| [Migrate to `Database.builder()`](migrating-to-database-builder.md) | Replace legacy `new DatabaseConfig()` and `DatabaseFactory.create(...)` code with `Database.builder()` and `DatabaseBuilder.build()`. Includes common rewrites, fluent builder equivalents, and manual-review cases for semi-automated upgrades |
+
## Entity beans
| Guide | Description |
@@ -133,6 +139,7 @@ tasks are at: https://github.com/ebean-orm/ebean/tree/HEAD/docs/guides/
Key guides (fetch and follow these when performing the relevant task):
- Maven POM setup: https://raw.githubusercontent.com/ebean-orm/ebean/HEAD/docs/guides/add-ebean-postgres-maven-pom.md
- Database configuration: https://raw.githubusercontent.com/ebean-orm/ebean/HEAD/docs/guides/add-ebean-postgres-database-config.md
+- Migrate to `Database.builder()`: https://raw.githubusercontent.com/ebean-orm/ebean/HEAD/docs/guides/migrating-to-database-builder.md
- Write queries with query beans: https://raw.githubusercontent.com/ebean-orm/ebean/HEAD/docs/guides/writing-ebean-query-beans.md
- Immutable bean cache for read-only references: https://raw.githubusercontent.com/ebean-orm/ebean/HEAD/docs/guides/immutable-bean-cache.md
- Persisting and transactions: https://raw.githubusercontent.com/ebean-orm/ebean/HEAD/docs/guides/persisting-and-transactions-with-ebean.md
@@ -158,6 +165,7 @@ tasks are at: https://github.com/ebean-orm/ebean/tree/HEAD/docs/guides/
Key guides (fetch and follow these when performing the relevant task):
- Maven POM setup: https://raw.githubusercontent.com/ebean-orm/ebean/HEAD/docs/guides/add-ebean-postgres-maven-pom.md
- Database configuration: https://raw.githubusercontent.com/ebean-orm/ebean/HEAD/docs/guides/add-ebean-postgres-database-config.md
+- Migrate to `Database.builder()`: https://raw.githubusercontent.com/ebean-orm/ebean/HEAD/docs/guides/migrating-to-database-builder.md
- Write queries with query beans: https://raw.githubusercontent.com/ebean-orm/ebean/HEAD/docs/guides/writing-ebean-query-beans.md
- Persisting and transactions: https://raw.githubusercontent.com/ebean-orm/ebean/HEAD/docs/guides/persisting-and-transactions-with-ebean.md
- Test container setup: https://raw.githubusercontent.com/ebean-orm/ebean/HEAD/docs/guides/add-ebean-postgres-test-container.md
diff --git a/docs/guides/add-ebean-postgres-database-config.md b/docs/guides/add-ebean-postgres-database-config.md
index 8e39f3105a..1fddb0a136 100644
--- a/docs/guides/add-ebean-postgres-database-config.md
+++ b/docs/guides/add-ebean-postgres-database-config.md
@@ -1,4 +1,4 @@
-# Guide: Add Ebean ORM (PostgreSQL) to an Existing Maven Project — Step 2: Database Configuration
+# Guide: Add Ebean ORM (PostgreSQL) to an Existing Maven Project — Step 3: Database Configuration
## Purpose
diff --git a/docs/guides/migrating-to-database-builder.md b/docs/guides/migrating-to-database-builder.md
new file mode 100644
index 0000000000..058edc5836
--- /dev/null
+++ b/docs/guides/migrating-to-database-builder.md
@@ -0,0 +1,242 @@
+# Guide: Migrate from `DatabaseConfig` / `DatabaseFactory` to `Database.builder()`
+
+## Purpose
+
+This guide shows how to migrate legacy programmatic database creation code from:
+
+- `new DatabaseConfig()`
+- `DatabaseFactory.create(...)`
+- old `setXxx(...)` builder-style configuration methods
+
+…to the preferred builder-based style using:
+
+- `Database.builder()`
+- fluent `DatabaseBuilder` methods such as `name(...)`, `register(...)`, and `defaultDatabase(...)`
+- `DatabaseBuilder.build()`
+
+Use this guide when upgrading older Ebean setup code or when building an automated/semi-automated migration.
+
+---
+
+## Preferred pattern
+
+Prefer code shaped like this:
+
+```java
+Database database = Database.builder()
+ .name("db")
+ .loadFromProperties()
+ .dataSourceBuilder(dataSource)
+ .register(true)
+ .defaultDatabase(true)
+ .build();
+```
+
+The important points are:
+
+1. Start with `Database.builder()`
+2. Configure via `DatabaseBuilder`
+3. Finish with `.build()`
+
+---
+
+## Step 1 — Replace `new DatabaseConfig()` with `Database.builder()`
+
+### Before
+
+```java
+DatabaseConfig config = new DatabaseConfig();
+config.setName("db");
+config.loadFromProperties();
+```
+
+### After
+
+```java
+DatabaseBuilder config = Database.builder()
+ .name("db")
+ .loadFromProperties();
+```
+
+### Notes
+
+- Prefer the `DatabaseBuilder` type for local variables and parameters when possible.
+- If existing code only uses standard builder methods, this change is usually mechanical.
+- If existing code later reads configuration back, use `config.settings()`.
+
+---
+
+## Step 2 — Replace `DatabaseFactory.create(config)` with `config.build()`
+
+### Before
+
+```java
+DatabaseConfig config = new DatabaseConfig();
+config.setName("db");
+config.loadFromProperties();
+Database database = DatabaseFactory.create(config);
+```
+
+### After
+
+```java
+DatabaseBuilder config = Database.builder()
+ .name("db")
+ .loadFromProperties();
+Database database = config.build();
+```
+
+### Short form
+
+```java
+Database database = Database.builder()
+ .name("db")
+ .loadFromProperties()
+ .build();
+```
+
+---
+
+## Step 3 — Replace `DatabaseFactory.create("name")`
+
+### Before
+
+```java
+Database database = DatabaseFactory.create("other");
+```
+
+### After
+
+```java
+Database database = Database.builder()
+ .name("other")
+ .loadFromProperties()
+ .build();
+```
+
+### Important
+
+For **named databases**, set `.name("...")` before `.loadFromProperties()` so the named configuration is loaded.
+
+---
+
+## Step 4 — Replace legacy `setXxx(...)` methods with fluent builder methods
+
+`DatabaseBuilder` already exposes preferred fluent names for most configuration methods.
+Use those names when migrating older setup code.
+
+| Legacy call | Preferred call |
+|---|---|
+| `setName("db")` | `name("db")` |
+| `setRegister(false)` | `register(false)` |
+| `setDefaultServer(false)` | `defaultDatabase(false)` |
+| `setContainerConfig(cfg)` | `containerConfig(cfg)` |
+| `setDbSchema("app")` | `dbSchema("app")` |
+| `setDataSourceConfig(ds)` | `dataSourceBuilder(ds)` |
+| `setReadOnlyDataSourceConfig(ro)` | `readOnlyDataSourceBuilder(ro)` |
+| `setRunMigration(true)` | `runMigration(true)` |
+| `setDisableClasspathSearch(true)` | `disableClasspathSearch(true)` |
+| `setPersistBatch(batch)` | `persistBatch(batch)` |
+
+### Full example
+
+#### Before
+
+```java
+DatabaseConfig config = new DatabaseConfig();
+config.setName("db");
+config.setRegister(false);
+config.setDefaultServer(false);
+config.setDataSourceConfig(dataSource);
+Database database = DatabaseFactory.create(config);
+```
+
+#### After
+
+```java
+Database database = Database.builder()
+ .name("db")
+ .register(false)
+ .defaultDatabase(false)
+ .dataSourceBuilder(dataSource)
+ .build();
+```
+
+---
+
+## Step 5 — Verify semantics after migration
+
+The migration should preserve behavior, but verify these points:
+
+- `register(true)` is still the default
+- `defaultDatabase(true)` is still the default
+- call `loadFromProperties()` if the old code loaded configuration from properties
+- for named databases, set the name before loading properties
+- explicit entity registration via `addClass(...)` / `addAll(...)` is unchanged
+- custom datasource wiring via `dataSourceBuilder(...)` and `readOnlyDataSourceBuilder(...)` is unchanged
+
+---
+
+## Manual-review cases
+
+These cases are **not** simple search-and-replace migrations and should be reviewed manually:
+
+### `DatabaseFactory.createWithContextClassLoader(...)`
+
+There is no direct builder shorthand for this today. Keep this as-is for now and migrate the surrounding builder configuration first.
+
+### `DatabaseFactory.initialiseContainer(...)`
+
+This is a container lifecycle concern, not a normal database-builder call. Keep it as-is unless you are intentionally moving the `ContainerConfig` onto the first builder via `containerConfig(...)`.
+
+### `DatabaseFactory.shutdown()`
+
+This is also a lifecycle concern rather than normal builder setup. Leave it alone unless you are making a deliberate lifecycle change.
+
+### Variables or method signatures typed as `DatabaseConfig`
+
+If the code only uses standard builder operations, switch the type to `DatabaseBuilder`.
+If the code depends on implementation-specific `DatabaseConfig` methods, review it manually.
+
+### Code that needs read access to builder settings
+
+Use:
+
+```java
+DatabaseBuilder builder = Database.builder();
+DatabaseBuilder.Settings settings = builder.settings();
+```
+
+rather than relying on the concrete `DatabaseConfig` type only to read getters.
+
+---
+
+## Automation notes for AI agents and bulk refactors
+
+This migration is a good candidate for semi-automated upgrading.
+
+### Safe mechanical rewrites
+
+These are usually safe to rewrite automatically:
+
+- `new DatabaseConfig()` → `Database.builder()`
+- `DatabaseFactory.create(builder)` → `builder.build()`
+- `DatabaseFactory.create("name")` → `Database.builder().name("name").loadFromProperties().build()`
+- legacy `setXxx(...)` calls → preferred fluent builder methods
+
+### Flag for manual review
+
+Automatically flag, but do not blindly rewrite:
+
+- `DatabaseFactory.createWithContextClassLoader(...)`
+- `DatabaseFactory.initialiseContainer(...)`
+- `DatabaseFactory.shutdown()`
+- parameters, fields, or return types declared as `DatabaseConfig`
+- any use that clearly depends on `DatabaseConfig` implementation details rather than `DatabaseBuilder`
+
+---
+
+## Related guides
+
+- [Database configuration](add-ebean-postgres-database-config.md) — preferred modern setup style using `Database.builder()`
+- [Guide index](README.md) — full list of Ebean setup and migration guides
diff --git a/ebean-api/src/main/java/io/ebean/Database.java b/ebean-api/src/main/java/io/ebean/Database.java
index 19df6c5e18..b5d5cd3aa2 100644
--- a/ebean-api/src/main/java/io/ebean/Database.java
+++ b/ebean-api/src/main/java/io/ebean/Database.java
@@ -23,11 +23,18 @@
/**
* Provides the API for fetching and saving beans to a particular database.
*
+ *
Constructing a Database
+ *
+ * Databases are typically constructed via {@link #builder()} and {@link DatabaseBuilder#build()}.
+ * They can also be automatically constructed on demand using configuration information in
+ * the application.properties file. The underlying implementation is provided by
+ * {@link DatabaseFactory}.
+ *
*
Registration with the DB singleton
*
- * When a Database instance is created it can be registered with the DB
- * singleton (see {@link DatabaseConfig#setRegister(boolean)}). The DB
- * singleton is essentially a map of Database's that have been registered
+ * When a Database instance is created it can be registered with the {@link DB}
+ * singleton (see {@link DatabaseBuilder#register(boolean)}). The {@link DB}
+ * singleton is essentially a map of {@link Database}'s that have been registered
* with it.
*
* The Database can then be retrieved later via {@link DB#byName(String)}.
@@ -35,16 +42,10 @@
*
The 'default' Database
*
* One Database can be designated as the 'default' or 'primary' Database
- * (see {@link DatabaseConfig#setDefaultServer(boolean)}). Many methods on DB
+ * (see {@link DatabaseBuilder#defaultDatabase(boolean)}). Many methods on {@link DB}
* such as {@link DB#find(Class)} etc are actually just a convenient way to
* call methods on the 'default/primary' Database.
*
- *
Constructing a Database
- *
- * Databases are constructed by the DatabaseFactory. They can be created
- * programmatically via {@link DatabaseFactory#create(DatabaseBuilder)} or they
- * can be automatically constructed on demand using configuration information in
- * the application.properties file.
*
*
Example: Get a Database
* {@code
@@ -80,6 +81,7 @@
* method. Example: a single thread requires more than one transaction.
*
* @see DB
+ * @see DatabaseBuilder
* @see DatabaseFactory
* @see DatabaseConfig
*/
@@ -94,11 +96,13 @@ public interface Database {
* // from application.properties / application.yaml
*
* Database db = Database.builder()
+ * .name("db")
* .loadFromProperties()
* .build();
*
* }
*/
+ @SuppressWarnings("removal")
static DatabaseBuilder builder() {
return new DatabaseConfig();
}
diff --git a/ebean-api/src/main/java/io/ebean/DatabaseBuilder.java b/ebean-api/src/main/java/io/ebean/DatabaseBuilder.java
index 530bf38504..0f1c6eeebb 100644
--- a/ebean-api/src/main/java/io/ebean/DatabaseBuilder.java
+++ b/ebean-api/src/main/java/io/ebean/DatabaseBuilder.java
@@ -982,7 +982,7 @@ default DatabaseBuilder namingConvention(NamingConvention namingConvention) {
*
* Use this to override the default known aggregation functions.
*/
- DatabaseConfig aggregateFormulaContext(AggregateFormulaContext aggregateFormulaContext);
+ DatabaseBuilder aggregateFormulaContext(AggregateFormulaContext aggregateFormulaContext);
/**
* Set to true if all DB column and table names should use quoted identifiers.
@@ -2221,7 +2221,7 @@ default DatabaseBuilder loadModuleInfo(boolean loadModuleInfo) {
*
* @param includeLabelInSql When true include a SQL inline comment in generated SELECT queries.
*/
- DatabaseConfig includeLabelInSql(boolean includeLabelInSql);
+ DatabaseBuilder includeLabelInSql(boolean includeLabelInSql);
/**
* Set the naming convention to apply to metrics names.
@@ -2239,7 +2239,7 @@ default DatabaseBuilder metricNaming(Function metricNaming) {
/**
* Sets the length check mode.
*/
- DatabaseConfig lengthCheck(LengthCheck lengthCheck);
+ DatabaseBuilder lengthCheck(LengthCheck lengthCheck);
/**
* Provides read access (getters) for the DatabaseBuilder configuration
diff --git a/ebean-api/src/main/java/io/ebean/DatabaseFactory.java b/ebean-api/src/main/java/io/ebean/DatabaseFactory.java
index cd0d9cd62f..51b6282c05 100644
--- a/ebean-api/src/main/java/io/ebean/DatabaseFactory.java
+++ b/ebean-api/src/main/java/io/ebean/DatabaseFactory.java
@@ -8,18 +8,18 @@
import java.util.concurrent.locks.ReentrantLock;
/**
- * Creates Database instances.
+ * Low-level factory for creating {@link Database} instances.
*
- * This uses either DatabaseConfig or properties in the application.properties file to
- * configure and create a Database instance.
+ * Most applications should prefer {@link Database#builder()} together with {@link DatabaseBuilder#build()}.
+ * This factory remains for legacy creation entry points plus container lifecycle methods.
*
- * The Database instance can either be registered with the DB singleton or
- * not. The DB singleton effectively holds a map of Database by a name.
- * If the Database is registered with the DB singleton you can retrieve it
+ * The Database instance can either be registered with the {@link DB} singleton or
+ * not. The {@link DB} singleton effectively holds a map of {@link Database} by name.
+ * If the Database is registered with the {@link DB} singleton you can retrieve it
* later via {@link DB#byName(String)}.
*
* One Database can be nominated as the 'default/primary' Database. Many
- * methods on the DB singleton such as {@link DB#find(Class)} are just a
+ * methods on the {@link DB} singleton such as {@link DB#find(Class)} are just a
* convenient way of using the 'default/primary' Database.
*/
public final class DatabaseFactory {
@@ -36,7 +36,8 @@ public final class DatabaseFactory {
* Initialise the container with clustering configuration.
*
* Call this prior to creating any Database instances or alternatively set the
- * ContainerConfig on the DatabaseConfig when creating the first Database instance.
+ * {@link ContainerConfig} on the first {@link DatabaseBuilder} via
+ * {@link DatabaseBuilder#containerConfig(ContainerConfig)}.
*/
public static void initialiseContainer(ContainerConfig containerConfig) {
lock.lock();
@@ -48,8 +49,11 @@ public static void initialiseContainer(ContainerConfig containerConfig) {
}
/**
- * Create using properties to configure the database.
+ * Create using configuration loaded from properties for the given database name.
+ *
+ * @deprecated migrate to {@code Database.builder().name(name).loadFromProperties().build()}.
*/
+ @Deprecated
public static Database create(String name) {
lock.lock();
try {
@@ -60,18 +64,9 @@ public static Database create(String name) {
}
/**
- * Create using the DatabaseConfig object to configure the database.
- *
- *
{@code
- *
- * DatabaseConfig config = new DatabaseConfig();
- * config.setName("db");
- * config.loadProperties();
- *
- * Database database = DatabaseFactory.create(config);
- *
- * }
+ * @deprecated migrate to {@link DatabaseBuilder#build()}.
*/
+ @Deprecated(forRemoval = true)
public static Database create(DatabaseBuilder builder) {
lock.lock();
try {
@@ -97,7 +92,8 @@ public static Database create(DatabaseBuilder builder) {
}
/**
- * Create using the DatabaseConfig additionally specifying a classLoader to use as the context class loader.
+ * Create using the {@link DatabaseBuilder}, additionally specifying a classLoader to use as the
+ * context class loader.
*/
public static Database createWithContextClassLoader(DatabaseBuilder config, ClassLoader classLoader) {
lock.lock();
diff --git a/ebean-api/src/main/java/io/ebean/DbContext.java b/ebean-api/src/main/java/io/ebean/DbContext.java
index a7694182ff..eddc890203 100644
--- a/ebean-api/src/main/java/io/ebean/DbContext.java
+++ b/ebean-api/src/main/java/io/ebean/DbContext.java
@@ -92,6 +92,7 @@ Database get(String name) {
/**
* Read, create and put of Databases.
*/
+ @SuppressWarnings("deprecation")
private Database getWithCreate(String name) {
lock.lock();
try {
diff --git a/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java b/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java
index 048c285972..3c36245733 100644
--- a/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java
+++ b/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java
@@ -31,38 +31,15 @@
import java.util.function.Function;
/**
- * The configuration used for creating a Database.
- *
- * Used to programmatically construct an Database and optionally register it
- * with the DB singleton.
- *
- * If you just use DB thout this programmatic configuration Ebean will read
- * the application.properties file and take the configuration from there. This usually
- * includes searching the class path and automatically registering any entity
- * classes and listeners etc.
- *
{@code
- *
- * DatabaseConfig config = new DatabaseConfig();
- *
- * // read the ebean.properties and load
- * // those settings into this DatabaseConfig object
- * config.loadFromProperties();
- *
- * // explicitly register the entity beans to avoid classpath scanning
- * config.addClass(Customer.class);
- * config.addClass(User.class);
- *
- * Database db = DatabaseFactory.create(config);
- *
- * }
+ * Deprecated migrate to {@link Database#builder()} rather than constructing {@code DatabaseConfig} directly.
*
*
- * Note that DatabaseConfigProvider provides a standard Java ServiceLoader mechanism that can
- * be used to apply configuration to the DatabaseConfig.
+ * Note that {@link DatabaseConfigProvider} provides a standard Java ServiceLoader mechanism that can
+ * be used to apply configuration to the {@link DatabaseBuilder}.
*
* @author emcgreal
* @author rbygrave
- * @see DatabaseFactory
+ * @see Database#builder()
*/
public class DatabaseConfig implements DatabaseBuilder.Settings {
@@ -558,12 +535,14 @@ public class DatabaseConfig implements DatabaseBuilder.Settings {
private Function metricNaming = MetricNamingMatch.INSTANCE;
/**
- * Construct a Database Configuration for programmatically creating an Database.
+ * @deprecated migrate to {@link Database#builder()} and configure the returned {@link DatabaseBuilder}.
*/
+ @Deprecated(forRemoval = true)
public DatabaseConfig() {
}
@Override
+ @SuppressWarnings("removal")
public Database build() {
return DatabaseFactory.create(this);
}
diff --git a/ebean-api/src/main/java/io/ebean/config/DatabaseConfigProvider.java b/ebean-api/src/main/java/io/ebean/config/DatabaseConfigProvider.java
index 68b8d9167b..f16388bb77 100644
--- a/ebean-api/src/main/java/io/ebean/config/DatabaseConfigProvider.java
+++ b/ebean-api/src/main/java/io/ebean/config/DatabaseConfigProvider.java
@@ -3,14 +3,14 @@
import io.ebean.DatabaseBuilder;
/**
- * Provides a ServiceLoader based mechanism to configure a DatabaseConfig.
+ * Provides a ServiceLoader based mechanism to configure a {@link DatabaseBuilder}.
*
* Provide an implementation and register it via the standard Java ServiceLoader mechanism
* via a file at META-INF/services/io.ebean.config.DatabaseConfigProvider.
*
*
* If you are using a DI container like Spring or Guice you are unlikely to use this but instead use a
- * spring specific configuration. When we are not using a DI container we may use this mechanism to
+ * spring specific configuration. When we are not using a DI container we may use this mechanism to
* explicitly register the entity beans and avoid classpath scanning.
*
* {@code
@@ -18,7 +18,7 @@
* public class EbeanConfigProvider implements DatabaseConfigProvider {
*
* @Override
- * public void apply(DatabaseConfig config) {
+ * public void apply(DatabaseBuilder config) {
*
* // register the entity bean classes explicitly
* config.addClass(Customer.class);
@@ -32,10 +32,9 @@
public interface DatabaseConfigProvider {
/**
- * Apply the configuration to the DatabaseConfig.
+ * Apply the configuration to the {@link DatabaseBuilder}.
*
* Typically we explicitly register entity bean classes and thus avoid classpath scanning.
- *
*/
void apply(DatabaseBuilder config);
}
diff --git a/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/model/build/ModelBuildBeanVisitorTest.java b/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/model/build/ModelBuildBeanVisitorTest.java
index 21650b6531..45c1d2f969 100644
--- a/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/model/build/ModelBuildBeanVisitorTest.java
+++ b/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/model/build/ModelBuildBeanVisitorTest.java
@@ -1,9 +1,7 @@
package io.ebeaninternal.dbmigration.model.build;
-
import io.ebean.DB;
-import io.ebean.DatabaseFactory;
-import io.ebean.config.DatabaseConfig;
+import io.ebean.Database;
import io.ebean.config.DbConstraintNaming;
import io.ebean.platform.h2.H2Platform;
import io.ebean.platform.sqlserver.SqlServer17Platform;
@@ -57,27 +55,25 @@ public void test_allQuoted() {
ModelContainer model = new ModelContainer();
- DatabaseConfig config = new DatabaseConfig();
- config.setName("h2");
- config.loadFromProperties();
- config.setName("h2other");
- config.setAllQuotedIdentifiers(true);
- config.setDdlGenerate(false);
- config.setDdlRun(false);
- config.setDdlExtra(false);
- config.setDefaultServer(false);
- config.setRegister(false);
-
- config.addClass(CKeyDetail.class);
- config.addClass(CKeyParent.class);
- config.addClass(CKeyAssoc.class);
- config.addClass(CKeyParentId.class);
- config.setDbOffline(true);
- config.setDatabasePlatform(new SqlServer17Platform());
-
- final SpiEbeanServer database = (SpiEbeanServer) DatabaseFactory.create(config);
+ final SpiEbeanServer database = (SpiEbeanServer) Database.builder()
+ .name("h2")
+ .loadFromProperties()
+ .name("h2other")
+ .allQuotedIdentifiers(true)
+ .ddlGenerate(false)
+ .ddlRun(false)
+ .ddlExtra(false)
+ .defaultDatabase(false)
+ .register(false)
+ .addClass(CKeyDetail.class)
+ .addClass(CKeyParent.class)
+ .addClass(CKeyAssoc.class)
+ .addClass(CKeyParentId.class)
+ .offline(true)
+ .databasePlatform(new SqlServer17Platform())
+ .build();
try {
- ModelBuildContext ctx = new ModelBuildContext(model, config.getDatabasePlatform(), config.getConstraintNaming(), true);
+ ModelBuildContext ctx = new ModelBuildContext(model, database.config().getDatabasePlatform(), database.config().getConstraintNaming(), true);
ModelBuildBeanVisitor addTable = new ModelBuildBeanVisitor(ctx);
diff --git a/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/model/build/ModelBuild_compoundKeyTest.java b/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/model/build/ModelBuild_compoundKeyTest.java
index 58a8f90621..d5b08d4477 100644
--- a/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/model/build/ModelBuild_compoundKeyTest.java
+++ b/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/model/build/ModelBuild_compoundKeyTest.java
@@ -1,10 +1,7 @@
package io.ebeaninternal.dbmigration.model.build;
-
-import io.ebean.DatabaseBuilder;
+import io.ebean.Database;
import io.localtest.BaseTestCase;
-import io.ebean.DatabaseFactory;
-import io.ebean.config.DatabaseConfig;
import io.ebeaninternal.api.SpiEbeanServer;
import io.ebeaninternal.dbmigration.ddlgeneration.Helper;
import io.ebeaninternal.dbmigration.migration.Migration;
@@ -25,23 +22,20 @@
public class ModelBuild_compoundKeyTest extends BaseTestCase {
private SpiEbeanServer createServer() {
-
- DatabaseBuilder config = new DatabaseConfig();
- config.setName("h2");
- config.loadFromProperties();
- config.setName("h2other");
- config.setDdlGenerate(false);
- config.setDdlRun(false);
- config.setDdlExtra(false);
- config.setDefaultServer(false);
- config.setRegister(false);
-
- config.addClass(CKeyDetail.class);
- config.addClass(CKeyParent.class);
- config.addClass(CKeyAssoc.class);
- config.addClass(CKeyParentId.class);
-
- return (SpiEbeanServer) DatabaseFactory.create(config);
+ return (SpiEbeanServer) Database.builder()
+ .name("h2")
+ .loadFromProperties()
+ .name("h2other")
+ .ddlGenerate(false)
+ .ddlRun(false)
+ .ddlExtra(false)
+ .defaultDatabase(false)
+ .register(false)
+ .addClass(CKeyDetail.class)
+ .addClass(CKeyParent.class)
+ .addClass(CKeyAssoc.class)
+ .addClass(CKeyParentId.class)
+ .build();
}
@Test
diff --git a/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/model/build/ModelBuild_compound_IdClassTest.java b/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/model/build/ModelBuild_compound_IdClassTest.java
index ce04296601..b8e2738713 100644
--- a/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/model/build/ModelBuild_compound_IdClassTest.java
+++ b/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/model/build/ModelBuild_compound_IdClassTest.java
@@ -1,10 +1,7 @@
package io.ebeaninternal.dbmigration.model.build;
-
-import io.ebean.DatabaseBuilder;
+import io.ebean.Database;
import io.localtest.BaseTestCase;
-import io.ebean.DatabaseFactory;
-import io.ebean.config.DatabaseConfig;
import io.ebeaninternal.api.SpiEbeanServer;
import io.ebeaninternal.dbmigration.ddlgeneration.Helper;
import io.ebeaninternal.dbmigration.model.CurrentModel;
@@ -21,18 +18,18 @@
public class ModelBuild_compound_IdClassTest extends BaseTestCase {
private SpiEbeanServer createServer() {
- DatabaseBuilder config = new DatabaseConfig();
- config.setName("h2");
- config.loadFromProperties();
- config.setName("h2other");
- config.setDdlGenerate(false);
- config.setDdlRun(false);
- config.setDdlExtra(false);
- config.setDefaultServer(false);
- config.setRegister(false);
- config.addClass(CKSiteUser.class);
- config.addClass(CKEmbId.class);
- return (SpiEbeanServer) DatabaseFactory.create(config);
+ return (SpiEbeanServer) Database.builder()
+ .name("h2")
+ .loadFromProperties()
+ .name("h2other")
+ .ddlGenerate(false)
+ .ddlRun(false)
+ .ddlExtra(false)
+ .defaultDatabase(false)
+ .register(false)
+ .addClass(CKSiteUser.class)
+ .addClass(CKEmbId.class)
+ .build();
}
@Test
diff --git a/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/model/build/ModelBuild_explicitSequencesTest.java b/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/model/build/ModelBuild_explicitSequencesTest.java
index 4e043b2bd3..9d46320947 100644
--- a/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/model/build/ModelBuild_explicitSequencesTest.java
+++ b/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/model/build/ModelBuild_explicitSequencesTest.java
@@ -1,9 +1,6 @@
package io.ebeaninternal.dbmigration.model.build;
-
-import io.ebean.DatabaseFactory;
-import io.ebean.DatabaseBuilder;
-import io.ebean.config.DatabaseConfig;
+import io.ebean.Database;
import io.ebeaninternal.api.SpiEbeanServer;
import io.ebeaninternal.dbmigration.ddlgeneration.DdlOptions;
import io.ebeaninternal.dbmigration.ddlgeneration.Helper;
@@ -20,22 +17,19 @@
class ModelBuild_explicitSequencesTest extends BaseTestCase {
private SpiEbeanServer createServer(boolean postgres) {
-
- DatabaseBuilder config = new DatabaseConfig();
- config.setName("h2");
- config.loadFromProperties();
- config.setName("h2other");
- config.setDdlGenerate(false);
- config.setDdlRun(false);
- config.setDdlExtra(false);
- config.setDefaultServer(false);
- config.setRegister(false);
-
- config.setDatabasePlatformName(postgres ? "postgres" : "h2");
-
- config.addClass(Person.class);
- config.addClass(Phone.class);
- return (SpiEbeanServer) DatabaseFactory.create(config);
+ return (SpiEbeanServer) Database.builder()
+ .name("h2")
+ .loadFromProperties()
+ .name("h2other")
+ .ddlGenerate(false)
+ .ddlRun(false)
+ .ddlExtra(false)
+ .defaultDatabase(false)
+ .register(false)
+ .databasePlatformName(postgres ? "postgres" : "h2")
+ .addClass(Person.class)
+ .addClass(Phone.class)
+ .build();
}
@Test
diff --git a/ebean-spring-txn/README.md b/ebean-spring-txn/README.md
index a49f215e2f..2577bcd0bd 100644
--- a/ebean-spring-txn/README.md
+++ b/ebean-spring-txn/README.md
@@ -12,13 +12,13 @@ to integrate with Springs JDBC Transaction manager.
## To use
```java
-DatabaseConfig config = new DatabaseConfig();
+DatabaseBuilder config = Database.builder();
// set SpringJdbcTransactionManager ... as the external transaction manager
config.setExternalTransactionManager(new SpringJdbcTransactionManager());
...
-Database database = DatabaseFactory.create(config);
+Database database = config.build();
```
diff --git a/ebean-spring-txn/src/test/java/org/example/EbeanServerFactoryBean.java b/ebean-spring-txn/src/test/java/org/example/EbeanServerFactoryBean.java
index db34c8827d..4cd0d7e2b8 100644
--- a/ebean-spring-txn/src/test/java/org/example/EbeanServerFactoryBean.java
+++ b/ebean-spring-txn/src/test/java/org/example/EbeanServerFactoryBean.java
@@ -1,7 +1,6 @@
package org.example;
import io.ebean.Database;
-import io.ebean.DatabaseFactory;
import io.ebean.annotation.PersistBatch;
import io.ebean.DatabaseBuilder;
import org.springframework.beans.factory.FactoryBean;
@@ -33,7 +32,7 @@ public void afterPropertiesSet() throws Exception {
serverConfig.setPersistBatch(PersistBatch.ALL);
// Create the new EbeanServer using the configuration
- this.ebeanServer = DatabaseFactory.create(serverConfig);
+ this.ebeanServer = serverConfig.build();
}
public Database getObject() throws Exception {
diff --git a/ebean-test/src/test/java/io/ebean/test/config/platform/ConfigTest.java b/ebean-test/src/test/java/io/ebean/test/config/platform/ConfigTest.java
index 94ed1a9bbb..d6e4cd9fc3 100644
--- a/ebean-test/src/test/java/io/ebean/test/config/platform/ConfigTest.java
+++ b/ebean-test/src/test/java/io/ebean/test/config/platform/ConfigTest.java
@@ -1,8 +1,8 @@
package io.ebean.test.config.platform;
+import io.ebean.Database;
import io.ebean.annotation.Platform;
import io.ebean.DatabaseBuilder;
-import io.ebean.config.DatabaseConfig;
import io.ebean.datasource.DataSourceBuilder;
import io.ebeaninternal.api.DbOffline;
import org.junit.jupiter.api.AfterAll;
@@ -29,7 +29,7 @@ static void after() {
@Test
void trimExtensions() {
- Config config = new Config("db", "db", "db", new DatabaseConfig());
+ Config config = new Config("db", "db", "db", Database.builder().settings());
assertThat(config.trimExtensions("a,b")).isEqualTo("a,b");
assertThat(config.trimExtensions(" a , b ")).isEqualTo("a,b");
@@ -38,10 +38,10 @@ void trimExtensions() {
@Test
void extensions_whenNoSetValues() {
- DatabaseConfig databaseBuilder = new DatabaseConfig();
+ DatabaseBuilder databaseBuilder = Database.builder();
databaseBuilder.loadFromProperties(new Properties());
- Config config = new Config("db", "postgis", "db", databaseBuilder);
+ Config config = new Config("db", "postgis", "db", databaseBuilder.settings());
config.setUsernameDefault();
config.setPasswordDefault();
@@ -56,13 +56,13 @@ void extensions_whenNoSetValues() {
@Test
void extensions_whenSetValues() {
- DatabaseConfig databaseBuilder = new DatabaseConfig();
+ DatabaseBuilder databaseBuilder = Database.builder();
Properties properties = new Properties();
properties.setProperty("ebean.test.extensions", "x,y");
properties.setProperty("ebean.test.extraDb.extensions", "z");
databaseBuilder.loadFromProperties(properties);
- Config config = new Config("db", "postgis", "db", databaseBuilder);
+ Config config = new Config("db", "postgis", "db", databaseBuilder.settings());
config.setExtensions("a,b");
config.setExtraExtensions("c,d");
@@ -78,7 +78,7 @@ void extraDbProperties_basic() {
Properties p = new Properties();
p.setProperty("ebean.test.extraDb", "other");
- DatabaseConfig serverConfig = new DatabaseConfig();
+ DatabaseBuilder.Settings serverConfig = Database.builder().settings();
serverConfig.loadFromProperties(p);
Config config = new Config("other", "postgres", "other", serverConfig);
@@ -100,7 +100,7 @@ void extraDbProperties_basic_extraDb_dbName() {
Properties p = new Properties();
p.setProperty("ebean.test.extraDb.dbName", "other");
- DatabaseConfig serverConfig = new DatabaseConfig();
+ DatabaseBuilder.Settings serverConfig = Database.builder().settings();
serverConfig.loadFromProperties(p);
Config config = new Config("other", "postgres", "other", serverConfig);
@@ -126,7 +126,7 @@ void extraDbProperties_withOptions() {
p.setProperty("ebean.test.extraDb.password", "other_pwd");
p.setProperty("ebean.test.extraDb.url", "other_url");
- DatabaseConfig serverConfig = new DatabaseConfig();
+ DatabaseBuilder.Settings serverConfig = Database.builder().settings();
serverConfig.setName("scOther");
serverConfig.loadFromProperties(p);
@@ -151,7 +151,7 @@ void extraDbProperties_withExtraDbOptions() {
sourceProperties.setProperty("ebean.test.dbName", "main");
sourceProperties.setProperty("ebean.test.extraDb.dbName", "central");
- DatabaseConfig serverConfig = new DatabaseConfig();
+ DatabaseBuilder.Settings serverConfig = Database.builder().settings();
serverConfig.setName("main");
serverConfig.loadFromProperties(sourceProperties);
@@ -164,8 +164,8 @@ void extraDbProperties_withExtraDbOptions() {
assertThat(mainProps.getProperty("datasource.main.username")).isEqualTo("main");
- DatabaseBuilder centralConfig = new DatabaseConfig();
- centralConfig.setName("central");
+ DatabaseBuilder centralConfig = Database.builder().settings();
+ centralConfig.name("central");
centralConfig.loadFromProperties(sourceProperties);
Config extraConfig = new Config("central", "postgres", "central", serverConfig);
@@ -220,10 +220,10 @@ void readImage_expect_platformSpecificWins() {
}
private Config createConfig(Properties p) {
- DatabaseConfig serverConfig = new DatabaseConfig();
- serverConfig.setName("scOther");
+ DatabaseBuilder serverConfig = Database.builder();
+ serverConfig.name("scOther");
serverConfig.loadFromProperties(p);
- return new Config("db_name", "postgres", "db_name", serverConfig);
+ return new Config("db_name", "postgres", "db_name", serverConfig.settings());
}
}
diff --git a/ebean-test/src/test/java/io/ebean/xtest/base/EbeanServerFactory_MultiTenancy_Test.java b/ebean-test/src/test/java/io/ebean/xtest/base/EbeanServerFactory_MultiTenancy_Test.java
index 3b5c54f35f..a50a243418 100644
--- a/ebean-test/src/test/java/io/ebean/xtest/base/EbeanServerFactory_MultiTenancy_Test.java
+++ b/ebean-test/src/test/java/io/ebean/xtest/base/EbeanServerFactory_MultiTenancy_Test.java
@@ -3,7 +3,6 @@
import io.ebean.DatabaseBuilder;
import io.ebean.xtest.BaseTestCase;
import io.ebean.Database;
-import io.ebean.DatabaseFactory;
import io.ebean.config.*;
import io.ebean.platform.mysql.MySqlPlatform;
import io.ebean.platform.postgres.PostgresPlatform;
@@ -28,7 +27,7 @@ public void create_new_server_with_multi_tenancy_db() {
TenantDataSourceProvider dataSourceProvider = Mockito.mock(TenantDataSourceProvider.class);
Mockito.doReturn(mockedDataSource).when(dataSourceProvider).dataSource(tenant);
- DatabaseBuilder config = new DatabaseConfig();
+ DatabaseBuilder config = Database.builder();
config.setName("multiTenantDb");
config.loadFromProperties();
config.setRegister(false);
@@ -44,7 +43,7 @@ public void create_new_server_with_multi_tenancy_db() {
//config.setDdlRun(false);
config.setDatabasePlatform(new PostgresPlatform());
- final Database database = DatabaseFactory.create(config);
+ final Database database = config.build();
database.shutdown();
}
@@ -63,7 +62,7 @@ public void create_new_server_with_multi_tenancy_schema() {
TenantSchemaProvider schemaProvider = Mockito.mock(TenantSchemaProvider.class);
Mockito.doReturn("tenant_schema").when(schemaProvider).schema(tenant);
- DatabaseBuilder config = new DatabaseConfig();
+ DatabaseBuilder config = Database.builder();
config.setName("h2");
config.loadFromProperties();
config.setName("multi-tenancy");
@@ -77,7 +76,7 @@ public void create_new_server_with_multi_tenancy_schema() {
config.setDdlRun(false);
config.setDatabasePlatform(new MySqlPlatform());
- final Database database = DatabaseFactory.create(config);
+ final Database database = config.build();
database.shutdown();
}
@@ -94,7 +93,7 @@ public void create_new_server_with_multi_tenancy_catalog() {
TenantCatalogProvider catalogProvider = Mockito.mock(TenantCatalogProvider.class);
Mockito.doReturn("tenant_catalog").when(catalogProvider).catalog(tenant);
- DatabaseBuilder config = new DatabaseConfig();
+ DatabaseBuilder config = Database.builder();
config.setName("h2");
config.loadFromProperties();
config.setName("multi-tenancy");
@@ -108,7 +107,7 @@ public void create_new_server_with_multi_tenancy_catalog() {
config.setDdlRun(false);
config.setDatabasePlatform(new MySqlPlatform());
- final Database database = DatabaseFactory.create(config);
+ final Database database = config.build();
database.shutdown();
}
}
diff --git a/ebean-test/src/test/java/io/ebean/xtest/base/EbeanServerFactory_ServerConfigStart_Test.java b/ebean-test/src/test/java/io/ebean/xtest/base/EbeanServerFactory_ServerConfigStart_Test.java
index 46e532b06a..fe90e61905 100644
--- a/ebean-test/src/test/java/io/ebean/xtest/base/EbeanServerFactory_ServerConfigStart_Test.java
+++ b/ebean-test/src/test/java/io/ebean/xtest/base/EbeanServerFactory_ServerConfigStart_Test.java
@@ -1,9 +1,7 @@
package io.ebean.xtest.base;
import io.ebean.Database;
-import io.ebean.DatabaseFactory;
import io.ebean.DatabaseBuilder;
-import io.ebean.config.DatabaseConfig;
import io.ebean.event.ServerConfigStartup;
import io.ebeaninternal.api.SpiLogger;
import io.ebeaninternal.api.SpiLoggerFactory;
@@ -46,7 +44,7 @@ public void debug(String msg, Object... args) {
@Test
public void test() throws InterruptedException {
- DatabaseBuilder config = new DatabaseConfig();
+ DatabaseBuilder config = Database.builder();
config.setName("h2");
config.loadFromProperties();
config.setName("h2other");
@@ -65,7 +63,7 @@ public void test() throws InterruptedException {
MySpiLoggerFactory loggerFactory = new MySpiLoggerFactory();
config.putServiceObject(SpiLoggerFactory.class, loggerFactory);
- Database db = DatabaseFactory.create(config);
+ Database db = config.build();
assertThat(loggerFactory.loggers).containsExactlyInAnyOrder("io.ebean.SQL", "io.ebean.SUM", "io.ebean.TXN");
@@ -77,7 +75,7 @@ public void test() throws InterruptedException {
// test server shutdown and restart using the same DatabaseConfig
db.shutdown(true, false);
- Database restartedServer = DatabaseFactory.create(config);
+ Database restartedServer = config.build();
restartedServer.shutdown(true, false);
}
diff --git a/ebean-test/src/test/java/io/ebean/xtest/config/PlatformNoGeneratedKeysTest.java b/ebean-test/src/test/java/io/ebean/xtest/config/PlatformNoGeneratedKeysTest.java
index db3c9622bd..0da86bce76 100644
--- a/ebean-test/src/test/java/io/ebean/xtest/config/PlatformNoGeneratedKeysTest.java
+++ b/ebean-test/src/test/java/io/ebean/xtest/config/PlatformNoGeneratedKeysTest.java
@@ -1,11 +1,9 @@
package io.ebean.xtest.config;
import io.ebean.Database;
-import io.ebean.DatabaseFactory;
import io.ebean.Transaction;
import io.ebean.annotation.Platform;
import io.ebean.DatabaseBuilder;
-import io.ebean.config.DatabaseConfig;
import io.ebean.config.dbplatform.DbIdentity;
import io.ebean.config.dbplatform.IdType;
import io.ebean.platform.h2.H2Platform;
@@ -89,7 +87,7 @@ public void insertNoBatch_expect_selectIdentity() {
private static Database testH2Server() {
- DatabaseConfig config = new DatabaseConfig();
+ DatabaseBuilder config = Database.builder();
config.setName("h2_noGeneratedKeys");
OtherH2Platform platform = new OtherH2Platform();
@@ -101,10 +99,10 @@ private static Database testH2Server() {
dbIdentity.setSelectLastInsertedIdTemplate("select identity() --{table}");
config.setDatabasePlatform(platform);
- config.getDataSourceConfig().setUsername("sa");
- config.getDataSourceConfig().setPassword("");
- config.getDataSourceConfig().setUrl("jdbc:h2:mem:withPCQuery;MODE=LEGACY");
- config.getDataSourceConfig().setDriver("org.h2.Driver");
+ config.settings().getDataSourceConfig().setUsername("sa");
+ config.settings().getDataSourceConfig().setPassword("");
+ config.settings().getDataSourceConfig().setUrl("jdbc:h2:mem:withPCQuery;MODE=LEGACY");
+ config.settings().getDataSourceConfig().setDriver("org.h2.Driver");
config.setDisableLazyLoading(true);
config.setDisableL2Cache(true);
@@ -116,7 +114,7 @@ private static Database testH2Server() {
config.addClass(BasicDraftableBean.class);
config.loadFromProperties(); // trigger auto config for H2 1.x
- return DatabaseFactory.create(config);
+ return config.build();
}
public static class OtherH2Platform extends H2Platform {
diff --git a/ebean-test/src/test/java/io/ebean/xtest/config/ServerConfigSqlServerTest.java b/ebean-test/src/test/java/io/ebean/xtest/config/ServerConfigSqlServerTest.java
index 6dc2f6dbac..608dc52532 100644
--- a/ebean-test/src/test/java/io/ebean/xtest/config/ServerConfigSqlServerTest.java
+++ b/ebean-test/src/test/java/io/ebean/xtest/config/ServerConfigSqlServerTest.java
@@ -1,11 +1,8 @@
package io.ebean.xtest.config;
-
import io.ebean.Database;
-import io.ebean.DatabaseFactory;
import io.ebean.annotation.Platform;
import io.ebean.DatabaseBuilder;
-import io.ebean.config.DatabaseConfig;
import io.ebean.xtest.ForPlatform;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
@@ -27,7 +24,7 @@ public void need_explicitPlatform() {
// no explicit databasePlatformName set ..
//props.setProperty("ebean.some_sqlserver.databasePlatformName", "sqlserver17");
- DatabaseBuilder config = new DatabaseConfig();
+ DatabaseBuilder config = Database.builder();
config.setName("some_sqlserver");
config.loadFromProperties(props);
@@ -39,7 +36,7 @@ public void need_explicitPlatform() {
config.setRegister(false);
config.addClass(EBasicVer.class);
- Database sqlServer = DatabaseFactory.create(config);
+ Database sqlServer = config.build();
assertThat(sqlServer).isNotNull();
sqlServer.shutdown();
@@ -62,7 +59,7 @@ public void explicit_17() {
String name = "testsqlserver17";
- DatabaseBuilder config = new DatabaseConfig();
+ DatabaseBuilder config = Database.builder();
config.setName(name);
Properties props = props(name);
@@ -80,7 +77,7 @@ public void explicit_17() {
config.loadFromProperties(props);
config.addClass(EBasicVer.class);
- Database sqlServer = DatabaseFactory.create(config);
+ Database sqlServer = config.build();
assertThat(sqlServer).isNotNull();
sqlServer.shutdown();
@@ -95,7 +92,7 @@ public void explicit_16() {
Properties props = props(name);
//props.setProperty("ebean.testsqlserver16.databasePlatformName", "sqlserver16");
- DatabaseBuilder config = new DatabaseConfig();
+ DatabaseBuilder config = Database.builder();
config.setDefaultServer(false);
config.setRegister(false);
config.setDdlGenerate(true);
@@ -106,7 +103,7 @@ public void explicit_16() {
config.loadFromProperties(props);
config.addClass(EBasicVer.class);
- Database sqlServer = DatabaseFactory.create(config);
+ Database sqlServer = config.build();
assertThat(sqlServer).isNotNull();
sqlServer.shutdown();
diff --git a/ebean-test/src/test/java/io/ebean/xtest/dbmigration/DbMigrationDropHistoryTest.java b/ebean-test/src/test/java/io/ebean/xtest/dbmigration/DbMigrationDropHistoryTest.java
index f1657ca272..26a41a894d 100644
--- a/ebean-test/src/test/java/io/ebean/xtest/dbmigration/DbMigrationDropHistoryTest.java
+++ b/ebean-test/src/test/java/io/ebean/xtest/dbmigration/DbMigrationDropHistoryTest.java
@@ -1,9 +1,7 @@
package io.ebean.xtest.dbmigration;
import io.ebean.Database;
-import io.ebean.DatabaseFactory;
import io.ebean.DatabaseBuilder;
-import io.ebean.config.DatabaseConfig;
import io.ebean.dbmigration.DbMigration;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
@@ -47,7 +45,7 @@ public static void main(String[] args) throws IOException {
migration.setPathToResources("src/test/resources");
- DatabaseBuilder config = new DatabaseConfig();
+ DatabaseBuilder config = Database.builder();
config.setName("migrationtest-history");
config.loadFromProperties();
config.setRegister(false);
@@ -55,7 +53,7 @@ public static void main(String[] args) throws IOException {
config.setPackages(Arrays.asList("misc.migration.history.v1_0"));
- Database server = DatabaseFactory.create(config);
+ Database server = config.build();
migration.setServer(server);
// First, we clean up the output-directory
@@ -71,7 +69,7 @@ public static void main(String[] args) throws IOException {
// and now for v1_1
config.setPackages(Arrays.asList("misc.migration.history.v1_1"));
server.shutdown();
- server = DatabaseFactory.create(config);
+ server = config.build();
migration.setServer(server);
assertThat(migration.generateMigration()).isEqualTo("1.1");
assertThat(migration.generateMigration()).isNull(); // subsequent call
diff --git a/ebean-test/src/test/java/io/ebean/xtest/dbmigration/DbMigrationGenerateTest.java b/ebean-test/src/test/java/io/ebean/xtest/dbmigration/DbMigrationGenerateTest.java
index 6d19a976b6..4bfbcb8f01 100644
--- a/ebean-test/src/test/java/io/ebean/xtest/dbmigration/DbMigrationGenerateTest.java
+++ b/ebean-test/src/test/java/io/ebean/xtest/dbmigration/DbMigrationGenerateTest.java
@@ -1,10 +1,8 @@
package io.ebean.xtest.dbmigration;
import io.ebean.Database;
-import io.ebean.DatabaseFactory;
import io.ebean.annotation.Platform;
import io.ebean.DatabaseBuilder;
-import io.ebean.config.DatabaseConfig;
import io.ebean.dbmigration.DbMigration;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
@@ -89,15 +87,15 @@ public static void run(String pathToResources) throws IOException {
migration.addPlatform(Platform.YUGABYTE);
- DatabaseConfig config = new DatabaseConfig();
+ DatabaseBuilder config = Database.builder();
config.setName("migrationtest");
config.loadFromProperties();
config.setRegister(false);
config.setDefaultServer(false);
- config.getProperties().put("ebean.hana.generateUniqueDdl", "true"); // need to generate unique statements to prevent them from being filtered out as duplicates by the DdlRunner
+ config.settings().getProperties().put("ebean.hana.generateUniqueDdl", "true"); // need to generate unique statements to prevent them from being filtered out as duplicates by the DdlRunner
config.setPackages(Arrays.asList("misc.migration.v1_0"));
- Database server = DatabaseFactory.create(config);
+ Database server = config.build();
migration.setServer(server);
// then we generate migration scripts for v1_0
@@ -108,7 +106,7 @@ public static void run(String pathToResources) throws IOException {
// and now for v1_1
config.setPackages(Arrays.asList("misc.migration.v1_1"));
server.shutdown();
- server = DatabaseFactory.create(config);
+ server = config.build();
migration.setServer(server);
assertThat(migration.generateMigration()).isEqualTo("1.1");
assertThat(migration.generateMigration()).isNull(); // subsequent call
@@ -128,7 +126,7 @@ public static void run(String pathToResources) throws IOException {
// and now for v1_2 with
config.setPackages(Arrays.asList("misc.migration.v1_2"));
server.shutdown();
- server = DatabaseFactory.create(config);
+ server = config.build();
migration.setServer(server);
assertThat(migration.generateMigration()).isEqualTo("1.3");
assertThat(migration.generateMigration()).isNull(); // subsequent call
diff --git a/ebean-test/src/test/java/io/ebean/xtest/dbmigration/DbMigrationTest.java b/ebean-test/src/test/java/io/ebean/xtest/dbmigration/DbMigrationTest.java
index 07f00ff7dc..7e2137aaf5 100644
--- a/ebean-test/src/test/java/io/ebean/xtest/dbmigration/DbMigrationTest.java
+++ b/ebean-test/src/test/java/io/ebean/xtest/dbmigration/DbMigrationTest.java
@@ -2,8 +2,8 @@
import io.ebean.*;
import io.ebean.annotation.Platform;
+import io.ebean.Database;
import io.ebean.DatabaseBuilder;
-import io.ebean.config.DatabaseConfig;
import io.ebean.config.dbplatform.DbHistorySupport;
import io.ebean.datasource.DataSourcePool;
import io.ebean.xtest.BaseTestCase;
@@ -217,7 +217,7 @@ private void testVersioning() {
if (history == null) {
return;
}
- DatabaseBuilder config = new DatabaseConfig();
+ DatabaseBuilder config = Database.builder();
config.setName(server().name());
config.loadFromProperties(server().pluginApi().config().getProperties());
config.setDataSource(server().dataSource());
@@ -227,7 +227,7 @@ private void testVersioning() {
config.setRegister(false);
config.setPackages(Collections.singletonList("misc.migration.v1_1"));
- Database tmpServer = DatabaseFactory.create(config);
+ Database tmpServer = config.build();
try {
EHistory hist = new misc.migration.v1_1.EHistory();
hist.setId(2);
@@ -289,7 +289,7 @@ private void testVersioning() {
// do some history tests with V1.1 models
private void testReservedKeywords() {
- DatabaseBuilder config = new DatabaseConfig();
+ DatabaseBuilder config = Database.builder();
config.setName(server().name());
config.loadFromProperties(server().pluginApi().config().getProperties());
config.setDataSource(server().dataSource());
@@ -299,7 +299,7 @@ private void testReservedKeywords() {
config.setRegister(false);
config.setPackages(Collections.singletonList("misc.migration.v1_0"));
- Database tmpServer = DatabaseFactory.create(config);
+ Database tmpServer = config.build();
try {
ETable table = new misc.migration.v1_0.ETable();
table.setFrom("foo");
diff --git a/ebean-test/src/test/java/io/ebean/xtest/event/BeanFindControllerTest.java b/ebean-test/src/test/java/io/ebean/xtest/event/BeanFindControllerTest.java
index 1a1a5da9ca..056e75b5e5 100644
--- a/ebean-test/src/test/java/io/ebean/xtest/event/BeanFindControllerTest.java
+++ b/ebean-test/src/test/java/io/ebean/xtest/event/BeanFindControllerTest.java
@@ -1,11 +1,9 @@
package io.ebean.xtest.event;
import io.ebean.Database;
-import io.ebean.DatabaseFactory;
import io.ebean.bean.BeanCollection;
import io.ebean.common.BeanList;
import io.ebean.DatabaseBuilder;
-import io.ebean.config.DatabaseConfig;
import io.ebean.event.BeanFindController;
import io.ebean.event.BeanQueryRequest;
import io.ebean.xtest.BaseTestCase;
@@ -27,7 +25,7 @@ public class BeanFindControllerTest extends BaseTestCase {
@Test
public void test() {
- var config = new DatabaseConfig();
+ DatabaseBuilder config = Database.builder();
config.setName("h2otherfind");
config.setRegister(false);
@@ -42,9 +40,9 @@ public void test() {
config.addClass(ECustomId.class);
EBasicFindController findController = new EBasicFindController();
- config.getFindControllers().add(findController);
+ config.settings().getFindControllers().add(findController);
- Database db = DatabaseFactory.create(config);
+ Database db = config.build();
assertFalse(findController.calledInterceptFind);
db.find(EBasic.class, 42);
@@ -170,7 +168,7 @@ public void testPostProcessFindMany() {
}
private Database prepareSoftRefs() {
- DatabaseConfig config = new DatabaseConfig();
+ DatabaseBuilder config = Database.builder();
config.setName("h2otherfind");
config.setRegister(false);
@@ -185,9 +183,9 @@ private Database prepareSoftRefs() {
config.addClass(SoftRefA.class);
config.addClass(SoftRefB.class);
- config.getFindControllers().add(new TestBeanFindController());
+ config.settings().getFindControllers().add(new TestBeanFindController());
- Database db = DatabaseFactory.create(config);
+ Database db = config.build();
final SoftRefA softRefA = new SoftRefA();
softRefA.setTitle("softRefA");
diff --git a/ebean-test/src/test/java/io/ebean/xtest/event/BeanPersistControllerTest.java b/ebean-test/src/test/java/io/ebean/xtest/event/BeanPersistControllerTest.java
index 7d635150f2..39ffcbae9a 100644
--- a/ebean-test/src/test/java/io/ebean/xtest/event/BeanPersistControllerTest.java
+++ b/ebean-test/src/test/java/io/ebean/xtest/event/BeanPersistControllerTest.java
@@ -1,16 +1,11 @@
package io.ebean.xtest.event;
-
import io.ebean.Database;
import io.ebean.DatabaseBuilder;
-import io.ebean.DatabaseFactory;
import io.ebean.Transaction;
-import io.ebean.config.DatabaseConfig;
import io.ebean.event.BeanDeleteIdRequest;
import io.ebean.event.BeanPersistAdapter;
-import io.ebean.event.BeanPersistController;
import io.ebean.event.BeanPersistRequest;
-import io.ebean.test.LoggedSql;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -151,7 +146,7 @@ public void testInsertUpdateDelete_given_stopPersistingAdapter() {
}
private Database createDatabase(PersistAdapter persistAdapter) {
- DatabaseBuilder config = new DatabaseConfig();
+ DatabaseBuilder config = Database.builder();
config.setName("h2ebasicver");
config.setRegister(false);
config.setDefaultServer(false);
@@ -165,7 +160,7 @@ private Database createDatabase(PersistAdapter persistAdapter) {
config.addClass(UTDetail.class);
config.add(persistAdapter);
- return DatabaseFactory.create(config);
+ return config.build();
}
static class PersistAdapter extends BeanPersistAdapter {
diff --git a/ebean-test/src/test/java/io/ebean/xtest/event/BeanPostLoadTest.java b/ebean-test/src/test/java/io/ebean/xtest/event/BeanPostLoadTest.java
index c22188bf8f..7e6bdc734d 100644
--- a/ebean-test/src/test/java/io/ebean/xtest/event/BeanPostLoadTest.java
+++ b/ebean-test/src/test/java/io/ebean/xtest/event/BeanPostLoadTest.java
@@ -1,12 +1,9 @@
package io.ebean.xtest.event;
-
import io.ebean.BeanState;
import io.ebean.DB;
import io.ebean.Database;
-import io.ebean.DatabaseFactory;
import io.ebean.DatabaseBuilder;
-import io.ebean.config.DatabaseConfig;
import io.ebean.event.BeanPostLoad;
import io.ebean.xtest.BaseTestCase;
import org.junit.jupiter.api.Test;
@@ -49,7 +46,7 @@ public void testPostLoad() {
private Database createDatabase() {
- DatabaseBuilder config = new DatabaseConfig();
+ DatabaseBuilder config = Database.builder();
config.setName("h2ebasicver");
config.setRegister(false);
@@ -63,7 +60,7 @@ private Database createDatabase() {
config.add(postLoad);
- return DatabaseFactory.create(config);
+ return config.build();
}
static class PostLoad implements BeanPostLoad {
diff --git a/ebean-test/src/test/java/io/ebean/xtest/internal/server/transaction/DefaultTransactionThreadLocalTest.java b/ebean-test/src/test/java/io/ebean/xtest/internal/server/transaction/DefaultTransactionThreadLocalTest.java
index 96a2353d80..86a46b14bc 100644
--- a/ebean-test/src/test/java/io/ebean/xtest/internal/server/transaction/DefaultTransactionThreadLocalTest.java
+++ b/ebean-test/src/test/java/io/ebean/xtest/internal/server/transaction/DefaultTransactionThreadLocalTest.java
@@ -2,11 +2,9 @@
import io.ebean.DB;
import io.ebean.Database;
-import io.ebean.DatabaseFactory;
import io.ebean.Transaction;
import io.ebean.annotation.Platform;
import io.ebean.DatabaseBuilder;
-import io.ebean.config.DatabaseConfig;
import io.ebean.xtest.BaseTestCase;
import io.ebean.xtest.ForPlatform;
import io.ebeaninternal.api.SpiTransaction;
@@ -132,7 +130,7 @@ public void usingDatabase() {
private Database createOtherDatabase() {
- DatabaseBuilder config = new DatabaseConfig();
+ DatabaseBuilder config = Database.builder();
config.setName("h2ebasicver");
config.loadFromProperties();
config.setDdlGenerate(true);
@@ -145,6 +143,6 @@ private Database createOtherDatabase() {
config.addClass(UTMaster.class);
config.addClass(UTDetail.class);
- return DatabaseFactory.create(config);
+ return config.build();
}
}
diff --git a/ebean-test/src/test/java/org/multitenant/partition/MultiTenantPartitionTest.java b/ebean-test/src/test/java/org/multitenant/partition/MultiTenantPartitionTest.java
index 2f976f5b02..86e86fc69d 100644
--- a/ebean-test/src/test/java/org/multitenant/partition/MultiTenantPartitionTest.java
+++ b/ebean-test/src/test/java/org/multitenant/partition/MultiTenantPartitionTest.java
@@ -1,9 +1,7 @@
package org.multitenant.partition;
import io.ebean.Database;
-import io.ebean.DatabaseFactory;
import io.ebean.DatabaseBuilder;
-import io.ebean.config.DatabaseConfig;
import io.ebean.config.TenantMode;
import io.ebean.test.LoggedSql;
import io.ebean.xtest.BaseTestCase;
@@ -120,7 +118,7 @@ private MtContent newContent(String title) {
}
private static Database init() {
- DatabaseBuilder config = new DatabaseConfig();
+ DatabaseBuilder config = Database.builder();
config.setName("h2multitenant");
config.loadFromProperties();
config.setDdlGenerate(true);
@@ -135,6 +133,6 @@ private static Database init() {
config.addClass(MtContent.class);
config.addClass(MtNone.class);
- return DatabaseFactory.create(config);
+ return config.build();
}
}
diff --git a/ebean-test/src/test/java/org/tests/basic/MainDbBoolean.java b/ebean-test/src/test/java/org/tests/basic/MainDbBoolean.java
index 985fb31f42..3888719ce5 100644
--- a/ebean-test/src/test/java/org/tests/basic/MainDbBoolean.java
+++ b/ebean-test/src/test/java/org/tests/basic/MainDbBoolean.java
@@ -1,11 +1,9 @@
package org.tests.basic;
import io.ebean.Database;
-import io.ebean.DatabaseFactory;
import io.ebean.Query;
import io.ebean.SqlRow;
import io.ebean.DatabaseBuilder;
-import io.ebean.config.DatabaseConfig;
import io.ebean.platform.postgres.PostgresPlatform;
import io.ebean.datasource.DataSourceConfig;
import org.tests.model.basic.TOne;
@@ -38,7 +36,7 @@ public static void main(String[] args) {
* DDL generation etc.
*/
private Database createOracleEbeanServer() {
- DatabaseBuilder c = new DatabaseConfig();
+ DatabaseBuilder c = Database.builder();
c.setName("ora");
c.setDdlExtra(false);
@@ -67,11 +65,11 @@ private Database createOracleEbeanServer() {
c.addClass(TSMaster.class);
c.addClass(TSDetail.class);
- return DatabaseFactory.create(c);
+ return c.build();
}
private Database createEbeanServer() {
- DatabaseBuilder c = new DatabaseConfig();
+ DatabaseBuilder c = Database.builder();
c.setName("pgtest");
c.setDdlExtra(false);
@@ -97,7 +95,7 @@ private Database createEbeanServer() {
c.setDatabasePlatform(new PostgresPlatform());
c.addClass(TOne.class);
- return DatabaseFactory.create(c);
+ return c.build();
}
private void simpleCheck(Database server) {
diff --git a/ebean-test/src/test/java/org/tests/basic/TestPersistenceContext.java b/ebean-test/src/test/java/org/tests/basic/TestPersistenceContext.java
index 3bfa60b613..7852391f07 100644
--- a/ebean-test/src/test/java/org/tests/basic/TestPersistenceContext.java
+++ b/ebean-test/src/test/java/org/tests/basic/TestPersistenceContext.java
@@ -1,11 +1,10 @@
package org.tests.basic;
import io.ebean.DB;
-import io.ebean.DatabaseFactory;
import io.ebean.QueryIterator;
import io.ebean.Transaction;
+import io.ebean.Database;
import io.ebean.DatabaseBuilder;
-import io.ebean.config.DatabaseConfig;
import io.ebean.xtest.BaseTestCase;
import io.ebeaninternal.api.SpiPersistenceContext;
import io.ebeaninternal.api.SpiTransaction;
@@ -250,16 +249,16 @@ public void setId(TmId id) {
@Test
@Disabled
void initDb() {
- DatabaseConfig config = new DatabaseConfig();
+ DatabaseBuilder config = Database.builder();
config.setName("h2-batch");
config.loadFromProperties();
config.setDdlExtra(false);
- config.getDataSourceConfig().setUsername("sa");
- config.getDataSourceConfig().setPassword("sa");
- config.getDataSourceConfig().setUrl("jdbc:h2:file:./testsFile3;DB_CLOSE_ON_EXIT=FALSE;NON_KEYWORDS=KEY,VALUE");
+ config.settings().getDataSourceConfig().setUsername("sa");
+ config.settings().getDataSourceConfig().setPassword("sa");
+ config.settings().getDataSourceConfig().setUrl("jdbc:h2:file:./testsFile3;DB_CLOSE_ON_EXIT=FALSE;NON_KEYWORDS=KEY,VALUE");
config.addClass(TestModel2.class);
config.addClass(TmId.class);
- DatabaseFactory.create(config);
+ config.build();
String base = "x".repeat(240);
// 10 mio TestModel - each needs about 1/4 kbytes -> 2,5 GB in total
@@ -284,16 +283,16 @@ void initDb() {
@Test
@Disabled
void testFindEachFindList() {
- DatabaseConfig config = new DatabaseConfig();
+ DatabaseBuilder config = Database.builder();
config.setName("h2-batch");
config.loadFromProperties();
config.setDdlRun(false);
- config.getDataSourceConfig().setUsername("sa");
- config.getDataSourceConfig().setPassword("sa");
- config.getDataSourceConfig().setUrl("jdbc:h2:file:./testsFile3;DB_CLOSE_ON_EXIT=FALSE;NON_KEYWORDS=KEY,VALUE");
+ config.settings().getDataSourceConfig().setUsername("sa");
+ config.settings().getDataSourceConfig().setPassword("sa");
+ config.settings().getDataSourceConfig().setUrl("jdbc:h2:file:./testsFile3;DB_CLOSE_ON_EXIT=FALSE;NON_KEYWORDS=KEY,VALUE");
config.addClass(TestModel2.class);
config.addClass(TmId.class);
- DatabaseFactory.create(config);
+ config.build();
AtomicInteger i = new AtomicInteger();
System.out.println("Doing findEach");
diff --git a/ebean-test/src/test/java/org/tests/basic/TestPersistenceContextMany.java b/ebean-test/src/test/java/org/tests/basic/TestPersistenceContextMany.java
index cf91280b71..491fb2f048 100644
--- a/ebean-test/src/test/java/org/tests/basic/TestPersistenceContextMany.java
+++ b/ebean-test/src/test/java/org/tests/basic/TestPersistenceContextMany.java
@@ -1,10 +1,9 @@
package org.tests.basic;
import io.ebean.DB;
-import io.ebean.DatabaseFactory;
import io.ebean.QueryIterator;
+import io.ebean.Database;
import io.ebean.DatabaseBuilder;
-import io.ebean.config.DatabaseConfig;
import io.ebean.xtest.BaseTestCase;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
@@ -98,19 +97,19 @@ public static class TestModel3Many2 {
@Test
@Disabled
void initDb() {
- DatabaseConfig config = new DatabaseConfig();
+ DatabaseBuilder config = Database.builder();
config.setName("h2-batch");
config.loadFromProperties();
config.setDdlExtra(false);
- config.getDataSourceConfig().setUsername("sa");
- config.getDataSourceConfig().setPassword("sa");
- config.getDataSourceConfig().setUrl("jdbc:h2:file:./testsFileMany;DB_CLOSE_ON_EXIT=FALSE;NON_KEYWORDS=KEY,VALUE");
+ config.settings().getDataSourceConfig().setUsername("sa");
+ config.settings().getDataSourceConfig().setPassword("sa");
+ config.settings().getDataSourceConfig().setUrl("jdbc:h2:file:./testsFileMany;DB_CLOSE_ON_EXIT=FALSE;NON_KEYWORDS=KEY,VALUE");
config.addClass(TestModel3.class);
config.addClass(TestModel3A.class);
config.addClass(TestModel3B.class);
config.addClass(TestModel3Many1.class);
config.addClass(TestModel3Many2.class);
- DatabaseFactory.create(config);
+ config.build();
String base = "x".repeat(240);
// 10 mio TestModel - each needs about 1/4 kbytes -> 2,5 GB in total
@@ -142,19 +141,19 @@ void initDb() {
@Test
@Disabled
void testFindEachFindList() {
- DatabaseConfig config = new DatabaseConfig();
+ DatabaseBuilder config = Database.builder();
config.setName("h2-batch");
config.loadFromProperties();
config.setDdlRun(false);
- config.getDataSourceConfig().setUsername("sa");
- config.getDataSourceConfig().setPassword("sa");
- config.getDataSourceConfig().setUrl("jdbc:h2:file:./testsFileMany;DB_CLOSE_ON_EXIT=FALSE;NON_KEYWORDS=KEY,VALUE");
+ config.settings().getDataSourceConfig().setUsername("sa");
+ config.settings().getDataSourceConfig().setPassword("sa");
+ config.settings().getDataSourceConfig().setUrl("jdbc:h2:file:./testsFileMany;DB_CLOSE_ON_EXIT=FALSE;NON_KEYWORDS=KEY,VALUE");
config.addClass(TestModel3.class);
config.addClass(TestModel3A.class);
config.addClass(TestModel3B.class);
config.addClass(TestModel3Many1.class);
config.addClass(TestModel3Many2.class);
- DatabaseFactory.create(config);
+ config.build();
AtomicInteger i = new AtomicInteger();
System.out.println("Doing findEach");
diff --git a/ebean-test/src/test/java/org/tests/cache/TestBeanCacheAsync.java b/ebean-test/src/test/java/org/tests/cache/TestBeanCacheAsync.java
index 9126172360..2b24879725 100644
--- a/ebean-test/src/test/java/org/tests/cache/TestBeanCacheAsync.java
+++ b/ebean-test/src/test/java/org/tests/cache/TestBeanCacheAsync.java
@@ -5,7 +5,6 @@
import io.ebean.xtest.BaseTestCase;
import io.ebean.DB;
import io.ebean.Database;
-import io.ebean.DatabaseFactory;
import io.ebeaninternal.server.cache.DefaultServerCachePlugin;
import org.junit.jupiter.api.Test;
import org.tests.model.basic.OCachedBean;
@@ -63,7 +62,7 @@ public Runnable wrap(Runnable task) {
@Test
public void findById_with_tenant() throws InterruptedException {
- DatabaseBuilder config = new DatabaseConfig();
+ DatabaseBuilder config = Database.builder();
config.setName(DB.getDefault().name());
config.loadFromProperties();
config.setDataSource(DB.getDefault().dataSource());
@@ -79,7 +78,7 @@ public void findById_with_tenant() throws InterruptedException {
new MdcBackgroundExecutorWrapper().with(new TenantCopyBackgroundExecutorWrapper()));
tenantId.set("4711");
- Database db = DatabaseFactory.create(config);
+ Database db = config.build();
try {
OCachedBean bean = new OCachedBean();
bean.setName("findById");
diff --git a/ebean-test/src/test/java/org/tests/changelog/TestChangeLog.java b/ebean-test/src/test/java/org/tests/changelog/TestChangeLog.java
index 4946a13346..f3d46a1e23 100644
--- a/ebean-test/src/test/java/org/tests/changelog/TestChangeLog.java
+++ b/ebean-test/src/test/java/org/tests/changelog/TestChangeLog.java
@@ -5,9 +5,7 @@
import io.ebean.DatabaseBuilder;
import io.ebean.xtest.BaseTestCase;
import io.ebean.Database;
-import io.ebean.DatabaseFactory;
import io.ebean.annotation.ChangeLog;
-import io.ebean.config.DatabaseConfig;
import io.ebean.event.BeanPersistRequest;
import io.ebean.event.changelog.*;
import io.ebean.test.LoggedSql;
@@ -172,7 +170,7 @@ public void testMutationWithCache() throws Exception {
private Database createServer() {
- DatabaseBuilder config = new DatabaseConfig();
+ DatabaseBuilder config = Database.builder();
config.setName("h2other");
config.loadFromProperties();
config.setDdlGenerate(true);
@@ -187,7 +185,7 @@ private Database createServer() {
config.setChangeLogListener(changeLogListener);
config.setChangeLogRegister(changeLogRegister);
- return DatabaseFactory.create(config);
+ return config.build();
}
static class TDChangeLogPrepare implements ChangeLogPrepare {
diff --git a/ebean-test/src/test/java/org/tests/json/TestJsonSourceDefault.java b/ebean-test/src/test/java/org/tests/json/TestJsonSourceDefault.java
index 91d83fd14b..1c620f7e0f 100644
--- a/ebean-test/src/test/java/org/tests/json/TestJsonSourceDefault.java
+++ b/ebean-test/src/test/java/org/tests/json/TestJsonSourceDefault.java
@@ -1,13 +1,11 @@
package org.tests.json;
import io.ebean.Database;
-import io.ebean.DatabaseFactory;
import io.ebean.ValuePair;
import io.ebean.DatabaseBuilder;
import io.ebean.xtest.ForPlatform;
import io.ebean.annotation.MutationDetection;
import io.ebean.annotation.Platform;
-import io.ebean.config.DatabaseConfig;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.tests.model.json.EBasicJsonList;
@@ -23,8 +21,8 @@ class TestJsonSourceDefault {
@ForPlatform(Platform.H2)
@Disabled
void testDirtyValues_diffSource() {
- DatabaseConfig config = new DatabaseConfig();
- config.getDataSourceConfig()
+ DatabaseBuilder config = Database.builder();
+ config.settings().getDataSourceConfig()
.setUsername("sa")
.setPassword("")
.setUrl("jdbc:h2:mem:testJsonSourceDirtyValues");
@@ -37,7 +35,7 @@ void testDirtyValues_diffSource() {
config.setDdlExtra(false);
config.addClass(EBasicJsonList.class);
config.setJsonMutationDetection(MutationDetection.SOURCE);
- Database db = DatabaseFactory.create(config);
+ Database db = config.build();
try {
assertThat(db).isNotNull();
diff --git a/ebean-test/src/test/java/org/tests/persistencecontext/TestPersistenceContextServerConfig.java b/ebean-test/src/test/java/org/tests/persistencecontext/TestPersistenceContextServerConfig.java
index fc515d2fe1..47d820b403 100644
--- a/ebean-test/src/test/java/org/tests/persistencecontext/TestPersistenceContextServerConfig.java
+++ b/ebean-test/src/test/java/org/tests/persistencecontext/TestPersistenceContextServerConfig.java
@@ -2,8 +2,8 @@
import io.ebean.*;
import io.ebean.config.ContainerConfig;
+import io.ebean.Database;
import io.ebean.DatabaseBuilder;
-import io.ebean.config.DatabaseConfig;
import io.ebean.xtest.BaseTestCase;
import io.ebeaninternal.api.SpiEbeanServer;
import io.ebeaninternal.api.SpiQuery;
@@ -31,7 +31,7 @@ public void test_config() {
static Database create() {
- DatabaseBuilder config = new DatabaseConfig();
+ DatabaseBuilder config = Database.builder();
config.setName("withPCQuery");
config.setDdlExtra(false);
@@ -48,6 +48,6 @@ static Database create() {
config.setRegister(false);
config.addClass(EBasicVer.class);
- return DatabaseFactory.create(config);
+ return config.build();
}
}
diff --git a/ebean-test/src/test/java/org/tests/readaudit/TestReadAudit.java b/ebean-test/src/test/java/org/tests/readaudit/TestReadAudit.java
index 5bbc948373..cb61490e35 100644
--- a/ebean-test/src/test/java/org/tests/readaudit/TestReadAudit.java
+++ b/ebean-test/src/test/java/org/tests/readaudit/TestReadAudit.java
@@ -3,11 +3,9 @@
import io.ebean.DatabaseBuilder;
import io.ebean.xtest.BaseTestCase;
import io.ebean.Database;
-import io.ebean.DatabaseFactory;
import io.ebean.FutureList;
import io.ebean.cache.ServerCache;
import io.ebean.cache.ServerCacheStatistics;
-import io.ebean.config.DatabaseConfig;
import io.ebean.event.readaudit.ReadAuditLogger;
import io.ebean.event.readaudit.ReadAuditPrepare;
import io.ebean.event.readaudit.ReadAuditQueryPlan;
@@ -303,7 +301,7 @@ public void test_findEach() {
private Database createServer() {
- DatabaseBuilder config = new DatabaseConfig();
+ DatabaseBuilder config = Database.builder();
config.setName("h2other");
config.loadFromProperties();
@@ -320,7 +318,7 @@ private Database createServer() {
config.setReadAuditLogger(readAuditLogger);
config.setReadAuditPrepare(readAuditPrepare);
- return DatabaseFactory.create(config);
+ return config.build();
}
private void resetCounters() {
diff --git a/ebean-test/src/test/java/org/tests/timezone/LocalTimeTest.java b/ebean-test/src/test/java/org/tests/timezone/LocalTimeTest.java
index 5ad4c8ce25..9b8ec3c35c 100644
--- a/ebean-test/src/test/java/org/tests/timezone/LocalTimeTest.java
+++ b/ebean-test/src/test/java/org/tests/timezone/LocalTimeTest.java
@@ -1,9 +1,7 @@
package org.tests.timezone;
import io.ebean.Database;
-import io.ebean.DatabaseFactory;
import io.ebean.DatabaseBuilder;
-import io.ebean.config.DatabaseConfig;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
@@ -53,7 +51,7 @@ public void testLocalTime() {
}
private Database createServer(String dbTimeZone) {
- DatabaseBuilder config = new DatabaseConfig();
+ DatabaseBuilder config = Database.builder();
config.setName(platform);
config.loadFromProperties();
config.setDdlExtra(false);
@@ -65,6 +63,6 @@ private Database createServer(String dbTimeZone) {
config.setDumpMetricsOnShutdown(false);
config.setDataTimeZone(dbTimeZone);
- return DatabaseFactory.create(config);
+ return config.build();
}
}
diff --git a/ebean-test/src/test/java/org/tests/unitinternal/HelloMain.java b/ebean-test/src/test/java/org/tests/unitinternal/HelloMain.java
index 6b79099409..acd979d9d2 100644
--- a/ebean-test/src/test/java/org/tests/unitinternal/HelloMain.java
+++ b/ebean-test/src/test/java/org/tests/unitinternal/HelloMain.java
@@ -3,7 +3,6 @@
import io.ebean.Database;
import io.ebean.DatabaseFactory;
import io.ebean.DatabaseBuilder;
-import io.ebean.config.DatabaseConfig;
import io.ebean.datasource.DataSourceConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -17,7 +16,7 @@ public class HelloMain {
public static void main(String[] args) {
// ### Configuration Objects ###
- DatabaseBuilder serverConfig = new DatabaseConfig();
+ DatabaseBuilder serverConfig = Database.builder();
DataSourceConfig dataSourceConfig = new DataSourceConfig();
// ### Configuration Settings ###
diff --git a/llms.txt b/llms.txt
index 2da5d9967d..dfa0234407 100644
--- a/llms.txt
+++ b/llms.txt
@@ -8,8 +8,9 @@
## Step-by-step guides (fetch and follow as needed)
- [Add Ebean + PostgreSQL — Step 1: Maven POM setup](https://raw.githubusercontent.com/ebean-orm/ebean/HEAD/docs/guides/add-ebean-postgres-maven-pom.md)
-- [Add Ebean + PostgreSQL — Step 2: Database configuration](https://raw.githubusercontent.com/ebean-orm/ebean/HEAD/docs/guides/add-ebean-postgres-database-config.md)
-- [Add Ebean + PostgreSQL — Step 3: Test container setup](https://raw.githubusercontent.com/ebean-orm/ebean/HEAD/docs/guides/add-ebean-postgres-test-container.md)
+- [Add Ebean + PostgreSQL — Step 2: Test container setup](https://raw.githubusercontent.com/ebean-orm/ebean/HEAD/docs/guides/add-ebean-postgres-test-container.md)
+- [Add Ebean + PostgreSQL — Step 3: Database configuration](https://raw.githubusercontent.com/ebean-orm/ebean/HEAD/docs/guides/add-ebean-postgres-database-config.md)
+- [Migrate to `Database.builder()`](https://raw.githubusercontent.com/ebean-orm/ebean/HEAD/docs/guides/migrating-to-database-builder.md)
- [Entity bean creation](https://raw.githubusercontent.com/ebean-orm/ebean/HEAD/docs/guides/entity-bean-creation.md)
- [Lombok with Ebean entity beans](https://raw.githubusercontent.com/ebean-orm/ebean/HEAD/docs/guides/lombok-with-ebean-entity-beans.md)
- [Write Ebean queries with query beans](https://raw.githubusercontent.com/ebean-orm/ebean/HEAD/docs/guides/writing-ebean-query-beans.md)
@@ -23,8 +24,9 @@
- [Guide index](https://raw.githubusercontent.com/ebean-orm/ebean/HEAD/docs/guides/README.md): Full index of the Ebean AI/developer guides, including setup, entities, querying, transactions, testing, and migrations.
- [Add Ebean + PostgreSQL — Step 1: Maven POM setup](https://raw.githubusercontent.com/ebean-orm/ebean/HEAD/docs/guides/add-ebean-postgres-maven-pom.md): Prescriptive instructions for modifying pom.xml — adds ebean-postgres, postgresql JDBC driver, ebean-maven-plugin, and querybean-generator annotation processor. Handles merging into existing annotationProcessorPaths blocks.
-- [Add Ebean + PostgreSQL — Step 2: Database configuration](https://raw.githubusercontent.com/ebean-orm/ebean/HEAD/docs/guides/add-ebean-postgres-database-config.md): Configure the Ebean Database bean using DataSourceBuilder and DatabaseConfig with Avaje Inject. Covers minimal (master-only) and extended (master + read-only replica) setup. Includes verification steps and troubleshooting table.
-- [Add Ebean + PostgreSQL — Step 3: Test container setup](https://raw.githubusercontent.com/ebean-orm/ebean/HEAD/docs/guides/add-ebean-postgres-test-container.md): Start a PostgreSQL or PostGIS Docker container for tests using ebean-test-containers and a @TestScope @Factory with Avaje Inject. Covers image mirror for CI/ECR, autoReadOnlyDataSource, dumpMetrics, PostGIS variant with optional LW/HexWKB mode, and keeping containers running locally.
+- [Add Ebean + PostgreSQL — Step 2: Test container setup](https://raw.githubusercontent.com/ebean-orm/ebean/HEAD/docs/guides/add-ebean-postgres-test-container.md): Start a PostgreSQL or PostGIS Docker container for tests using ebean-test-containers and a @TestScope @Factory with Avaje Inject. Covers image mirror for CI/ECR, autoReadOnlyDataSource, dumpMetrics, PostGIS variant with optional LW/HexWKB mode, and keeping containers running locally.
+- [Add Ebean + PostgreSQL — Step 3: Database configuration](https://raw.githubusercontent.com/ebean-orm/ebean/HEAD/docs/guides/add-ebean-postgres-database-config.md): Configure the Ebean Database bean using DataSourceBuilder together with `Database.builder()` / `DatabaseBuilder` and Avaje Inject. Covers minimal (master-only) and extended (master + read-only replica) setup. Includes verification steps and troubleshooting table.
+- [Migrate to `Database.builder()`](https://raw.githubusercontent.com/ebean-orm/ebean/HEAD/docs/guides/migrating-to-database-builder.md): Replace legacy `new DatabaseConfig()` and `DatabaseFactory.create(...)` code with `Database.builder()` and `DatabaseBuilder.build()`. Covers common rewrites, fluent builder method equivalents, and manual-review cases that should be flagged during semi-automated upgrades.
- [Entity bean creation](https://raw.githubusercontent.com/ebean-orm/ebean/HEAD/docs/guides/entity-bean-creation.md): Generate clean, idiomatic Ebean entity beans. Covers required annotations, recommended field patterns, relationships, audit fields, and anti-patterns such as public fields, `Set` collections, or custom equals/hashCode.
- [Lombok with Ebean entity beans](https://raw.githubusercontent.com/ebean-orm/ebean/HEAD/docs/guides/lombok-with-ebean-entity-beans.md): Which Lombok annotations to use and avoid on entity beans. Explains why @Data is incompatible (hashCode/equals breaks entity identity, toString triggers lazy loading). Prescribes @Getter + @Setter + @Accessors(chain=true). Includes compatibility table for common Lombok annotations.
- [Write Ebean queries with query beans](https://raw.githubusercontent.com/ebean-orm/ebean/HEAD/docs/guides/writing-ebean-query-beans.md): Prefer Q-bean queries for type-safe ORM queries. Covers choosing `exists()`/`findOne()`/`findList()`/`findPagedList()`, tuning `select()` / `fetch()` / `fetchQuery()` / `FetchGroup`, using `setUnmodifiable(true)` for read-only entity graphs, and projecting to DTOs when entity beans are not the right output.