From e2d666df35cf6e3607eba87af2f4317c5987d769 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Sat, 4 Nov 2023 13:05:22 +1300 Subject: [PATCH] Use fluid setters for DatabaseConfig and DatabaseBuilder --- .../src/main/java/io/ebean/Database.java | 17 + .../main/java/io/ebean/DatabaseBuilder.java | 596 +++++++++--------- .../java/io/ebean/config/DatabaseConfig.java | 495 ++++++++++----- .../deploy/BeanDescriptor_registerTest.java | 22 +- 4 files changed, 676 insertions(+), 454 deletions(-) diff --git a/ebean-api/src/main/java/io/ebean/Database.java b/ebean-api/src/main/java/io/ebean/Database.java index 6c3b5e7fe..a7427a9dc 100644 --- a/ebean-api/src/main/java/io/ebean/Database.java +++ b/ebean-api/src/main/java/io/ebean/Database.java @@ -86,6 +86,23 @@ import java.util.concurrent.Callable; @NonNullApi public interface Database { + /** + * Return a new database builder. + *
{@code
+ *
+ *   // build the 'default' database using configuration
+ *   // from application.properties / application.yaml
+ *
+ *   Database db = Database.builder()
+ *     .loadFromProperties()
+ *     .build();
+ *
+ * }
+ */ + static DatabaseBuilder builder() { + return new DatabaseConfig(); + } + /** * Shutdown the Database instance. */ diff --git a/ebean-api/src/main/java/io/ebean/DatabaseBuilder.java b/ebean-api/src/main/java/io/ebean/DatabaseBuilder.java index e69bcc100..1975ddd0e 100644 --- a/ebean-api/src/main/java/io/ebean/DatabaseBuilder.java +++ b/ebean-api/src/main/java/io/ebean/DatabaseBuilder.java @@ -1,9 +1,6 @@ package io.ebean; import com.fasterxml.jackson.core.JsonFactory; -import io.ebean.PersistenceContextScope; -import io.ebean.Query; -import io.ebean.Transaction; import io.ebean.annotation.*; import io.ebean.cache.ServerCachePlugin; import io.ebean.config.*; @@ -25,31 +22,172 @@ import java.time.Clock; import java.util.*; import java.util.function.Function; +/** + * Build a Database instance. + * + *
{@code
+ *
+ *   // build the 'default' database using configuration
+ *   // from application.properties / application.yaml
+ *
+ *   Database db = Database.builder()
+ *     .loadFromProperties()
+ *     .build();
+ *
+ * }
+ * + * Create a non-default database and not register it with {@link DB}. When + * not registered the database can not by obtained via {@link DB#byName(String)}. + * + *
{@code
+ *
+ *   Database database = Database.builder()
+ *     .setName("other"
+ *     .loadFromProperties()
+ *     .setRegister(false)
+ *     .setDefaultServer(false)
+ *     .addClass(EBasic.class)
+ *     .build();
+ *
+ * }
+ */ public interface DatabaseBuilder { + /** + * Build and return the Database instance. + */ + Database build(); + + /** + * Return the settings to read the configuration that has been set. This + * provides the getters/accessors to read the configuration properties. + */ Settings settings(); + /** + * Set the name of the Database. + */ + DatabaseBuilder setName(String name); + + /** + * Set to false if you do not want this server to be registered with the Ebean + * singleton when it is created. + *

+ * By default, this is set to true. + */ + DatabaseBuilder setRegister(boolean register); + + /** + * Set false if you do not want this Database to be registered as the "default" database + * with the DB singleton. + *

+ * This is only used when {@link #setRegister(boolean)} is also true. + */ + DatabaseBuilder setDefaultServer(boolean defaultServer); + + /** + * Set the DB schema to use. This specifies to use this schema for: + *

+ */ + DatabaseBuilder setDbSchema(String dbSchema); + + /** + * Set the Geometry SRID. + */ + DatabaseBuilder setGeometrySRID(int geometrySRID); + + /** + * Set the time zone to use when reading/writing Timestamps via JDBC. + */ + DatabaseBuilder setDataTimeZone(String dataTimeZone); + + /** + * Set the JDBC batch mode to use at the transaction level. + *

+ * When INSERT or ALL is used then save(), delete() etc do not execute immediately but instead go into + * a JDBC batch execute buffer that is flushed. The buffer is flushed if a query is executed, transaction ends + * or the batch size is meet. + */ + DatabaseBuilder setPersistBatch(PersistBatch persistBatch); + + /** + * Set the JDBC batch mode to use per save(), delete(), insert() or update() request. + *

+ * This makes sense when a save() or delete() etc cascades and executes multiple child statements. The best caase + * for this is when saving a master/parent bean this cascade inserts many detail/child beans. + *

+ * This only takes effect when the persistBatch mode at the transaction level does not take effect. + */ + DatabaseBuilder setPersistBatchOnCascade(PersistBatch persistBatchOnCascade); + + /** + * Deprecated, please migrate to using setPersistBatch(). + *

+ * Set to true if you what to use JDBC batching for persisting and deleting beans. + *

+ * With this Ebean will batch up persist requests and use the JDBC batch api. + * This is a performance optimisation designed to reduce the network chatter. + *

+ * When true this is equivalent to {@code setPersistBatch(PersistBatch.ALL)} or + * when false to {@code setPersistBatch(PersistBatch.NONE)} + */ + DatabaseBuilder setPersistBatching(boolean persistBatching); + + /** + * Set the batch size used for JDBC batching. If unset this defaults to 20. + *

+ * You can also set the batch size on the transaction. + * + * @see Transaction#setBatchSize(int) + */ + DatabaseBuilder setPersistBatchSize(int persistBatchSize); + + + /** + * Set to true to disable lazy loading by default. + *

+ * It can be turned on per query via {@link Query#setDisableLazyLoading(boolean)}. + */ + DatabaseBuilder setDisableLazyLoading(boolean disableLazyLoading); + + /** + * Set the default batch size for lazy loading. + *

+ * This is the number of beans or collections loaded when lazy loading is + * invoked by default. + *

+ * The default value is for this is 10 (load 10 beans or collections). + *

+ * You can explicitly control the lazy loading batch size for a given join on + * a query using +lazy(batchSize) or JoinConfig. + */ + DatabaseBuilder setLazyLoadBatchSize(int lazyLoadBatchSize); + /** * Set the clock used for setting the timestamps (e.g. @UpdatedTimestamp) on objects. */ - void setClock(Clock clock); + DatabaseBuilder setClock(Clock clock); /** * Set the slow query time in millis. */ - void setSlowQueryMillis(long slowQueryMillis); + DatabaseBuilder setSlowQueryMillis(long slowQueryMillis); /** * Set the slow query event listener. */ - void setSlowQueryListener(SlowQueryListener slowQueryListener); + DatabaseBuilder setSlowQueryListener(SlowQueryListener slowQueryListener); /** * Put a service object into configuration such that it can be used by ebean or a plugin. *

* For example, put IgniteConfiguration in to be passed to the Ignite plugin. */ - void putServiceObject(String key, Object configObject); + DatabaseBuilder putServiceObject(String key, Object configObject); /** * Put a service object into configuration such that it can be used by ebean or a plugin. @@ -64,7 +202,7 @@ public interface DatabaseBuilder { *

  • ServerCacheNotifyPlugin
  • * */ - void putServiceObject(Class iface, T configObject); + DatabaseBuilder putServiceObject(Class iface, T configObject); /** * Put a service object into configuration such that it can be used by ebean or a plugin. @@ -77,44 +215,38 @@ public interface DatabaseBuilder { * * } */ - void putServiceObject(Object configObject); + DatabaseBuilder putServiceObject(Object configObject); /** * Set the Jackson JsonFactory to use. *

    * If not set a default implementation will be used. */ - void setJsonFactory(JsonFactory jsonFactory); + DatabaseBuilder setJsonFactory(JsonFactory jsonFactory); /** * Set the JSON format to use for DateTime types. */ - void setJsonDateTime(JsonConfig.DateTime jsonDateTime); + DatabaseBuilder setJsonDateTime(JsonConfig.DateTime jsonDateTime); /** * Set the JSON format to use for Date types. */ - void setJsonDate(JsonConfig.Date jsonDate); + DatabaseBuilder setJsonDate(JsonConfig.Date jsonDate); /** * Set the JSON include mode used when writing JSON. *

    * Set to NON_NULL or NON_EMPTY to suppress nulls or null and empty collections respectively. */ - void setJsonInclude(JsonConfig.Include jsonInclude); + DatabaseBuilder setJsonInclude(JsonConfig.Include jsonInclude); /** * Set the default MutableDetection to use with {@code @DbJson} using Jackson. * * @see DbJson#mutationDetection() */ - void setJsonMutationDetection(MutationDetection jsonMutationDetection); - - /** - * Set the name of the Database. - */ - void setName(String name); - + DatabaseBuilder setJsonMutationDetection(MutationDetection jsonMutationDetection); /** * Set the container / clustering configuration. @@ -122,144 +254,57 @@ public interface DatabaseBuilder { * The container holds all the Database instances and provides clustering communication * services to all the Database instances. */ - void setContainerConfig(ContainerConfig containerConfig); - - /** - * Set to false if you do not want this server to be registered with the Ebean - * singleton when it is created. - *

    - * By default this is set to true. - */ - void setRegister(boolean register); - - /** - * Set false if you do not want this Database to be registered as the "default" database - * with the DB singleton. - *

    - * This is only used when {@link #setRegister(boolean)} is also true. - */ - void setDefaultServer(boolean defaultServer); + DatabaseBuilder setContainerConfig(ContainerConfig containerConfig); /** * Set the CurrentUserProvider. This is used to populate @WhoCreated, @WhoModified and * support other audit features (who executed a query etc). */ - void setCurrentUserProvider(CurrentUserProvider currentUserProvider); + DatabaseBuilder setCurrentUserProvider(CurrentUserProvider currentUserProvider); /** * Set the tenancy mode to use. */ - void setTenantMode(TenantMode tenantMode); + DatabaseBuilder setTenantMode(TenantMode tenantMode); /** * Set the column name used for TenantMode.PARTITION. */ - void setTenantPartitionColumn(String tenantPartitionColumn); + DatabaseBuilder setTenantPartitionColumn(String tenantPartitionColumn); /** * Set the current tenant provider. */ - void setCurrentTenantProvider(CurrentTenantProvider currentTenantProvider); + DatabaseBuilder setCurrentTenantProvider(CurrentTenantProvider currentTenantProvider); /** * Set the tenancy datasource provider. */ - void setTenantDataSourceProvider(TenantDataSourceProvider tenantDataSourceProvider); + DatabaseBuilder setTenantDataSourceProvider(TenantDataSourceProvider tenantDataSourceProvider); /** * Set the tenancy schema provider. */ - void setTenantSchemaProvider(TenantSchemaProvider tenantSchemaProvider); - - /** - * Return the tenancy catalog provider. - */ - TenantCatalogProvider getTenantCatalogProvider(); + DatabaseBuilder setTenantSchemaProvider(TenantSchemaProvider tenantSchemaProvider); /** * Set the tenancy catalog provider. */ - void setTenantCatalogProvider(TenantCatalogProvider tenantCatalogProvider); - - /** - * Return true if dirty beans are automatically persisted. - */ - boolean isAutoPersistUpdates(); + DatabaseBuilder setTenantCatalogProvider(TenantCatalogProvider tenantCatalogProvider); /** * Set to true if dirty beans are automatically persisted. */ - void setAutoPersistUpdates(boolean autoPersistUpdates); - - /** - * Set the JDBC batch mode to use at the transaction level. - *

    - * When INSERT or ALL is used then save(), delete() etc do not execute immediately but instead go into - * a JDBC batch execute buffer that is flushed. The buffer is flushed if a query is executed, transaction ends - * or the batch size is meet. - */ - void setPersistBatch(PersistBatch persistBatch); - - /** - * Set the JDBC batch mode to use per save(), delete(), insert() or update() request. - *

    - * This makes sense when a save() or delete() etc cascades and executes multiple child statements. The best caase - * for this is when saving a master/parent bean this cascade inserts many detail/child beans. - *

    - * This only takes effect when the persistBatch mode at the transaction level does not take effect. - */ - void setPersistBatchOnCascade(PersistBatch persistBatchOnCascade); - - /** - * Deprecated, please migrate to using setPersistBatch(). - *

    - * Set to true if you what to use JDBC batching for persisting and deleting beans. - *

    - * With this Ebean will batch up persist requests and use the JDBC batch api. - * This is a performance optimisation designed to reduce the network chatter. - *

    - * When true this is equivalent to {@code setPersistBatch(PersistBatch.ALL)} or - * when false to {@code setPersistBatch(PersistBatch.NONE)} - */ - void setPersistBatching(boolean persistBatching); - - /** - * Set the batch size used for JDBC batching. If unset this defaults to 20. - *

    - * You can also set the batch size on the transaction. - * - * @see Transaction#setBatchSize(int) - */ - void setPersistBatchSize(int persistBatchSize); + DatabaseBuilder setAutoPersistUpdates(boolean autoPersistUpdates); /** * Sets the query batch size. This defaults to 100. * * @param queryBatchSize the new query batch size */ - void setQueryBatchSize(int queryBatchSize); + DatabaseBuilder setQueryBatchSize(int queryBatchSize); - void setDefaultEnumType(EnumType defaultEnumType); - - /** - * Set to true to disable lazy loading by default. - *

    - * It can be turned on per query via {@link Query#setDisableLazyLoading(boolean)}. - */ - void setDisableLazyLoading(boolean disableLazyLoading); - - /** - * Set the default batch size for lazy loading. - *

    - * This is the number of beans or collections loaded when lazy loading is - * invoked by default. - *

    - * The default value is for this is 10 (load 10 beans or collections). - *

    - * You can explicitly control the lazy loading batch size for a given join on - * a query using +lazy(batchSize) or JoinConfig. - */ - void setLazyLoadBatchSize(int lazyLoadBatchSize); + DatabaseBuilder setDefaultEnumType(EnumType defaultEnumType); /** * Set the number of sequences to fetch/preallocate when using DB sequences. @@ -268,17 +313,17 @@ public interface DatabaseBuilder { * requests a sequence to be used as an Id for a bean (aka reduce network * chatter). */ - void setDatabaseSequenceBatchSize(int databaseSequenceBatchSize); + DatabaseBuilder setDatabaseSequenceBatchSize(int databaseSequenceBatchSize); /** * Set the default JDBC fetchSize hint for findList queries. */ - void setJdbcFetchSizeFindList(int jdbcFetchSizeFindList); + DatabaseBuilder setJdbcFetchSizeFindList(int jdbcFetchSizeFindList); /** * Set the default JDBC fetchSize hint for findEach/findEachWhile queries. */ - void setJdbcFetchSizeFindEach(int jdbcFetchSizeFindEach); + DatabaseBuilder setJdbcFetchSizeFindEach(int jdbcFetchSizeFindEach); /** * Set the ChangeLogPrepare. @@ -286,37 +331,37 @@ public interface DatabaseBuilder { * This is used to set user context information to the ChangeSet in the * foreground thread prior to the logging occurring in a background thread. */ - void setChangeLogPrepare(ChangeLogPrepare changeLogPrepare); + DatabaseBuilder setChangeLogPrepare(ChangeLogPrepare changeLogPrepare); /** * Set the ChangeLogListener which actually performs the logging of change sets * in the background. */ - void setChangeLogListener(ChangeLogListener changeLogListener); + DatabaseBuilder setChangeLogListener(ChangeLogListener changeLogListener); /** * Set the ChangeLogRegister which controls which ChangeLogFilter is used for each * bean type and in this way provide fine grained control over which persist requests * are included in the change log. */ - void setChangeLogRegister(ChangeLogRegister changeLogRegister); + DatabaseBuilder setChangeLogRegister(ChangeLogRegister changeLogRegister); /** * Set if inserts should be included in the change log by default. */ - void setChangeLogIncludeInserts(boolean changeLogIncludeInserts); + DatabaseBuilder setChangeLogIncludeInserts(boolean changeLogIncludeInserts); /** * Sets if the changelog should be written async (default = true). */ - void setChangeLogAsync(boolean changeLogAsync); + DatabaseBuilder setChangeLogAsync(boolean changeLogAsync); /** * Set the ReadAuditLogger to use. If not set the default implementation is used * which logs the read events in JSON format to a standard named SLF4J logger * (which can be configured in say logback to log to a separate log file). */ - void setReadAuditLogger(ReadAuditLogger readAuditLogger); + DatabaseBuilder setReadAuditLogger(ReadAuditLogger readAuditLogger); /** * Set the ReadAuditPrepare to use. @@ -325,133 +370,113 @@ public interface DatabaseBuilder { * (user id, user ip address etc) and sets it on the ReadEvent bean before it is sent * to the ReadAuditLogger. */ - void setReadAuditPrepare(ReadAuditPrepare readAuditPrepare); + DatabaseBuilder setReadAuditPrepare(ReadAuditPrepare readAuditPrepare); /** * Set the configuration for profiling. */ - void setProfilingConfig(ProfilingConfig profilingConfig); - - /** - * Set the DB schema to use. This specifies to use this schema for: - *

      - *
    • Running Database migrations - Create and use the DB schema
    • - *
    • Testing DDL - Create-all.sql DDL execution creates and uses schema
    • - *
    • Testing Docker - Set default schema on connection URL
    • - *
    - */ - void setDbSchema(String dbSchema); - - /** - * Set the Geometry SRID. - */ - void setGeometrySRID(int geometrySRID); - - /** - * Set the time zone to use when reading/writing Timestamps via JDBC. - */ - void setDataTimeZone(String dataTimeZone); + DatabaseBuilder setProfilingConfig(ProfilingConfig profilingConfig); /** * Set the suffix appended to the base table to derive the view that contains the union * of the base table and the history table in order to support asOf queries. */ - void setAsOfViewSuffix(String asOfViewSuffix); + DatabaseBuilder setAsOfViewSuffix(String asOfViewSuffix); /** * Set the database column used to support history and 'As of' queries. This column is a timestamp range * or equivalent. */ - void setAsOfSysPeriod(String asOfSysPeriod); + DatabaseBuilder setAsOfSysPeriod(String asOfSysPeriod); /** * Set the history table suffix. */ - void setHistoryTableSuffix(String historyTableSuffix); + DatabaseBuilder setHistoryTableSuffix(String historyTableSuffix); /** * Set to true if we are running in a JTA Transaction manager. */ - void setUseJtaTransactionManager(boolean useJtaTransactionManager); + DatabaseBuilder setUseJtaTransactionManager(boolean useJtaTransactionManager); /** * Set the external transaction manager. */ - void setExternalTransactionManager(ExternalTransactionManager externalTransactionManager); + DatabaseBuilder setExternalTransactionManager(ExternalTransactionManager externalTransactionManager); /** * Set the ServerCachePlugin to use. */ - void setServerCachePlugin(ServerCachePlugin serverCachePlugin); + DatabaseBuilder setServerCachePlugin(ServerCachePlugin serverCachePlugin); /** * Set to true if you want LOB's to be fetch eager by default. * By default this is set to false and LOB's must be explicitly fetched. */ - void setEagerFetchLobs(boolean eagerFetchLobs); + DatabaseBuilder setEagerFetchLobs(boolean eagerFetchLobs); /** * Set the max call stack to use for origin location. */ - void setMaxCallStack(int maxCallStack); + DatabaseBuilder setMaxCallStack(int maxCallStack); /** * Set to true if transactions should by default rollback on checked exceptions. */ - void setTransactionRollbackOnChecked(boolean transactionRollbackOnChecked); + DatabaseBuilder setTransactionRollbackOnChecked(boolean transactionRollbackOnChecked); /** * Set the Background executor schedule pool size. */ - void setBackgroundExecutorSchedulePoolSize(int backgroundExecutorSchedulePoolSize); + DatabaseBuilder setBackgroundExecutorSchedulePoolSize(int backgroundExecutorSchedulePoolSize); /** * Set the Background executor shutdown seconds. This is the time allowed for the pool to shutdown nicely * before it is forced shutdown. */ - void setBackgroundExecutorShutdownSecs(int backgroundExecutorShutdownSecs); + DatabaseBuilder setBackgroundExecutorShutdownSecs(int backgroundExecutorShutdownSecs); /** * Sets the background executor wrapper. The wrapper is used when a task is sent to background and should copy the thread-locals. */ - void setBackgroundExecutorWrapper(BackgroundExecutorWrapper backgroundExecutorWrapper); + DatabaseBuilder setBackgroundExecutorWrapper(BackgroundExecutorWrapper backgroundExecutorWrapper); /** * Set the L2 cache default max size. */ - void setCacheMaxSize(int cacheMaxSize); + DatabaseBuilder setCacheMaxSize(int cacheMaxSize); /** * Set the L2 cache default max idle time in seconds. */ - void setCacheMaxIdleTime(int cacheMaxIdleTime); + DatabaseBuilder setCacheMaxIdleTime(int cacheMaxIdleTime); /** * Set the L2 cache default max time to live in seconds. */ - void setCacheMaxTimeToLive(int cacheMaxTimeToLive); + DatabaseBuilder setCacheMaxTimeToLive(int cacheMaxTimeToLive); /** * Set the L2 query cache default max size. */ - void setQueryCacheMaxSize(int queryCacheMaxSize); + DatabaseBuilder setQueryCacheMaxSize(int queryCacheMaxSize); /** * Set the L2 query cache default max idle time in seconds. */ - void setQueryCacheMaxIdleTime(int queryCacheMaxIdleTime); + DatabaseBuilder setQueryCacheMaxIdleTime(int queryCacheMaxIdleTime); /** * Set the L2 query cache default max time to live in seconds. */ - void setQueryCacheMaxTimeToLive(int queryCacheMaxTimeToLive); + DatabaseBuilder setQueryCacheMaxTimeToLive(int queryCacheMaxTimeToLive); /** * Set the NamingConvention. *

    * If none is set the default UnderscoreNamingConvention is used. */ - void setNamingConvention(NamingConvention namingConvention); + DatabaseBuilder setNamingConvention(NamingConvention namingConvention); /** * Set to true if all DB column and table names should use quoted identifiers. @@ -459,37 +484,37 @@ public interface DatabaseBuilder { * For Postgres pgjdbc version 42.3.0 should be used with datasource property * quoteReturningIdentifiers set to false (refer #2303). */ - void setAllQuotedIdentifiers(boolean allQuotedIdentifiers); + DatabaseBuilder setAllQuotedIdentifiers(boolean allQuotedIdentifiers); /** * Set to true if this Database is Document store only instance (has no JDBC DB). */ - void setDocStoreOnly(boolean docStoreOnly); + DatabaseBuilder setDocStoreOnly(boolean docStoreOnly); /** * Set the configuration for the ElasticSearch integration. */ - void setDocStoreConfig(DocStoreConfig docStoreConfig); + DatabaseBuilder setDocStoreConfig(DocStoreConfig docStoreConfig); /** * Set the constraint naming convention used in DDL generation. */ - void setConstraintNaming(DbConstraintNaming constraintNaming); + DatabaseBuilder setConstraintNaming(DbConstraintNaming constraintNaming); /** * Set the configuration for AutoTune. */ - void setAutoTuneConfig(AutoTuneConfig autoTuneConfig); + DatabaseBuilder setAutoTuneConfig(AutoTuneConfig autoTuneConfig); /** * Set to true to skip the startup DataSource check. */ - void setSkipDataSourceCheck(boolean skipDataSourceCheck); + DatabaseBuilder setSkipDataSourceCheck(boolean skipDataSourceCheck); /** * Set a DataSource. */ - void setDataSource(DataSource dataSource); + DatabaseBuilder setDataSource(DataSource dataSource); /** * Set the read only DataSource. @@ -500,23 +525,23 @@ public interface DatabaseBuilder { * This read only DataSource will be used for implicit query only transactions. It is not * used if the transaction is created explicitly or if the query is an update or delete query. */ - void setReadOnlyDataSource(DataSource readOnlyDataSource); + DatabaseBuilder setReadOnlyDataSource(DataSource readOnlyDataSource); /** * Set the configuration required to build a DataSource using Ebean's own * DataSource implementation. */ - void setDataSourceConfig(DataSourceBuilder dataSourceConfig); + DatabaseBuilder setDataSourceConfig(DataSourceBuilder dataSourceConfig); /** * Set to true if Ebean should create a DataSource for use with implicit read only transactions. */ - void setAutoReadOnlyDataSource(boolean autoReadOnlyDataSource); + DatabaseBuilder setAutoReadOnlyDataSource(boolean autoReadOnlyDataSource); /** * Set the configuration for the read only DataSource. */ - void setReadOnlyDataSourceConfig(DataSourceBuilder readOnlyDataSourceConfig); + DatabaseBuilder setReadOnlyDataSourceConfig(DataSourceBuilder readOnlyDataSourceConfig); /** * Set the value to represent TRUE in the database. @@ -525,7 +550,7 @@ public interface DatabaseBuilder { *

    * The value set is either a Integer or a String (e.g. "1", or "T"). */ - void setDatabaseBooleanTrue(String databaseTrue); + DatabaseBuilder setDatabaseBooleanTrue(String databaseTrue); /** * Set the value to represent FALSE in the database. @@ -534,7 +559,7 @@ public interface DatabaseBuilder { *

    * The value set is either a Integer or a String (e.g. "0", or "F"). */ - void setDatabaseBooleanFalse(String databaseFalse); + DatabaseBuilder setDatabaseBooleanFalse(String databaseFalse); /** * Set the number of DB sequence values that should be preallocated and cached @@ -549,7 +574,7 @@ public interface DatabaseBuilder { * the cache drops to have full (which is 5 by default) Ebean will fetch * another batch of Id's in a background thread. */ - void setDatabaseSequenceBatch(int databaseSequenceBatchSize); + DatabaseBuilder setDatabaseSequenceBatch(int databaseSequenceBatchSize); /** * Explicitly set the database platform name @@ -564,7 +589,7 @@ public interface DatabaseBuilder { *

    * Values are oracle, h2, postgres, mysql, sqlserver16, sqlserver17. */ - void setDatabasePlatformName(String databasePlatformName); + DatabaseBuilder setDatabasePlatformName(String databasePlatformName); /** * Explicitly set the database platform to use. @@ -572,12 +597,12 @@ public interface DatabaseBuilder { * If none is set then the platform is determined via the databasePlatformName * or automatically via the JDBC driver information. */ - void setDatabasePlatform(DatabasePlatform databasePlatform); + DatabaseBuilder setDatabasePlatform(DatabasePlatform databasePlatform); /** * Set the preferred DB platform IdType. */ - void setIdType(IdType idType); + DatabaseBuilder setIdType(IdType idType); /** * Set the EncryptKeyManager. @@ -591,7 +616,7 @@ public interface DatabaseBuilder { * ebean.encryptKeyManager=org.avaje.tests.basic.encrypt.BasicEncyptKeyManager * } */ - void setEncryptKeyManager(EncryptKeyManager encryptKeyManager); + DatabaseBuilder setEncryptKeyManager(EncryptKeyManager encryptKeyManager); /** * Set the EncryptDeployManager. @@ -599,7 +624,7 @@ public interface DatabaseBuilder { * This is optionally used to programmatically define which columns are * encrypted instead of using the {@link Encrypted} Annotation. */ - void setEncryptDeployManager(EncryptDeployManager encryptDeployManager); + DatabaseBuilder setEncryptDeployManager(EncryptDeployManager encryptDeployManager); /** * Set the Encryptor used to encrypt data on the java client side (as opposed @@ -608,7 +633,7 @@ public interface DatabaseBuilder { * Ebean has a default implementation that it will use if you do not set your * own Encryptor implementation. */ - void setEncryptor(Encryptor encryptor); + DatabaseBuilder setEncryptor(Encryptor encryptor); /** * Set to true if the Database instance should be created in offline mode. @@ -616,7 +641,7 @@ public interface DatabaseBuilder { * Typically used to create an Database instance for DDL Migration generation * without requiring a real DataSource / Database to connect to. */ - void setDbOffline(boolean dbOffline); + DatabaseBuilder setDbOffline(boolean dbOffline); /** * Set the DbEncrypt used to encrypt and decrypt properties. @@ -624,47 +649,46 @@ public interface DatabaseBuilder { * Note that if this is not set then the DbPlatform may already have a * DbEncrypt set (H2, MySql, Postgres and Oracle platforms have a DbEncrypt) */ - void setDbEncrypt(DbEncrypt dbEncrypt); + DatabaseBuilder setDbEncrypt(DbEncrypt dbEncrypt); /** * Set the configuration for DB platform (such as UUID and custom mappings). */ - void setPlatformConfig(PlatformConfig platformConfig); - + DatabaseBuilder setPlatformConfig(PlatformConfig platformConfig); /** * Set the DB type used to store UUID. */ - void setDbUuid(PlatformConfig.DbUuid dbUuid); + DatabaseBuilder setDbUuid(PlatformConfig.DbUuid dbUuid); /** * Sets the UUID version mode. */ - void setUuidVersion(DatabaseConfig.UuidVersion uuidVersion); + DatabaseBuilder setUuidVersion(DatabaseConfig.UuidVersion uuidVersion); /** * Set the UUID state file. */ - void setUuidStateFile(String uuidStateFile); + DatabaseBuilder setUuidStateFile(String uuidStateFile); /** * Sets the V1-UUID-NodeId. */ - void setUuidNodeId(String uuidNodeId); + DatabaseBuilder setUuidNodeId(String uuidNodeId); /** * Set to true if LocalTime should be persisted with nanos precision. *

    * Otherwise it is persisted using java.sql.Time which is seconds precision. */ - void setLocalTimeWithNanos(boolean localTimeWithNanos); + DatabaseBuilder setLocalTimeWithNanos(boolean localTimeWithNanos); /** * Set to true if Duration should be persisted with nanos precision (SQL DECIMAL). *

    * Otherwise it is persisted with second precision (SQL INTEGER). */ - void setDurationWithNanos(boolean durationWithNanos); + DatabaseBuilder setDurationWithNanos(boolean durationWithNanos); /** * Set to true to run DB migrations on server start. @@ -672,7 +696,7 @@ public interface DatabaseBuilder { * This is the same as config.getMigrationConfig().setRunMigration(). We have added this method here * as it is often the only thing we need to configure for migrations. */ - void setRunMigration(boolean runMigration); + DatabaseBuilder setRunMigration(boolean runMigration); /** * Set to true to generate the "create all" DDL on startup. @@ -680,7 +704,7 @@ public interface DatabaseBuilder { * Typically we want this on when we are running tests locally (and often using H2) * and we want to create the full DB schema from scratch to run tests. */ - void setDdlGenerate(boolean ddlGenerate); + DatabaseBuilder setDdlGenerate(boolean ddlGenerate); /** * Set to true to run the generated "create all DDL" on startup. @@ -688,14 +712,14 @@ public interface DatabaseBuilder { * Typically we want this on when we are running tests locally (and often using H2) * and we want to create the full DB schema from scratch to run tests. */ - void setDdlRun(boolean ddlRun); + DatabaseBuilder setDdlRun(boolean ddlRun); /** * Set to false if you not want to run the extra-ddl.xml scripts. (default = true) *

    * Typically we want this on when we are running tests. */ - void setDdlExtra(boolean ddlExtra); + DatabaseBuilder setDdlExtra(boolean ddlExtra); /** * Set to true if the "drop all ddl" should be skipped. @@ -703,7 +727,7 @@ public interface DatabaseBuilder { * Typically we want to do this when using H2 (in memory) as our test database and the drop statements * are not required so skipping the drop table statements etc makes it faster with less noise in the logs. */ - void setDdlCreateOnly(boolean ddlCreateOnly); + DatabaseBuilder setDdlCreateOnly(boolean ddlCreateOnly); /** * Set a SQL script to execute after the "create all" DDL has been run. @@ -711,49 +735,44 @@ public interface DatabaseBuilder { * Typically this is a sql script that inserts test seed data when running tests. * Place a sql script in src/test/resources that inserts test seed data. */ - void setDdlSeedSql(String ddlSeedSql); + DatabaseBuilder setDdlSeedSql(String ddlSeedSql); /** * Set a SQL script to execute before the "create all" DDL has been run. */ - void setDdlInitSql(String ddlInitSql); + DatabaseBuilder setDdlInitSql(String ddlInitSql); /** * Set the header to use with DDL generation. */ - void setDdlHeader(String ddlHeader); - - /** - * Return true if strict mode is used which includes a check that non-null columns have a default value. - */ - boolean isDdlStrictMode(); + DatabaseBuilder setDdlHeader(String ddlHeader); /** * Set to false to turn off strict mode allowing non-null columns to not have a default value. */ - void setDdlStrictMode(boolean ddlStrictMode); + DatabaseBuilder setDdlStrictMode(boolean ddlStrictMode); /** * Set a comma and equals delimited placeholders that are substituted in DDL scripts. */ - void setDdlPlaceholders(String ddlPlaceholders); + DatabaseBuilder setDdlPlaceholders(String ddlPlaceholders); /** * Set a map of placeholder values that are substituted in DDL scripts. */ - void setDdlPlaceholderMap(Map ddlPlaceholderMap); + DatabaseBuilder setDdlPlaceholderMap(Map ddlPlaceholderMap); /** * Set to true to disable the class path search even for the case where no entity bean classes * have been registered. This can be used to start an Database instance just to use the * SQL functions such as SqlQuery, SqlUpdate etc. */ - void setDisableClasspathSearch(boolean disableClasspathSearch); + DatabaseBuilder setDisableClasspathSearch(boolean disableClasspathSearch); /** * Set the mode to use for Joda LocalTime support 'normal' or 'utc'. */ - void setJodaLocalTimeMode(String jodaLocalTimeMode); + DatabaseBuilder setJodaLocalTimeMode(String jodaLocalTimeMode); /** * Programmatically add classes (typically entities) that this server should use. @@ -766,26 +785,26 @@ public interface DatabaseBuilder { * * @param cls the entity type (or other type) that should be registered by this database. */ - void addClass(Class cls); + DatabaseBuilder addClass(Class cls); /** * Register all the classes (typically entity classes). */ - void addAll(Collection> classList); + DatabaseBuilder addAll(Collection> classList); /** * Add a package to search for entities via class path search. *

    * This is only used if classes have not been explicitly specified. */ - void addPackage(String packageName); + DatabaseBuilder addPackage(String packageName); /** * Set packages to search for entities via class path search. *

    * This is only used if classes have not been explicitly specified. */ - void setPackages(List packages); + DatabaseBuilder setPackages(List packages); /** * Set the list of classes (entities, listeners, scalarTypes etc) that should @@ -796,12 +815,12 @@ public interface DatabaseBuilder { *

    * Alternatively the classes can contain added via {@link #addClass(Class)}. */ - void setClasses(Collection> classes); + DatabaseBuilder classes(Collection> classes); /** * Set to false when we still want to hit the cache after a write has occurred on a transaction. */ - void setSkipCacheAfterWrite(boolean skipCacheAfterWrite); + DatabaseBuilder setSkipCacheAfterWrite(boolean skipCacheAfterWrite); /** * Set to false if by default updates in JDBC batch should not include all properties. @@ -810,13 +829,12 @@ public interface DatabaseBuilder { * * @see Transaction#setUpdateAllLoadedProperties(boolean) */ - void setUpdateAllPropertiesInBatch(boolean updateAllPropertiesInBatch); + DatabaseBuilder setUpdateAllPropertiesInBatch(boolean updateAllPropertiesInBatch); /** * Sets the resource directory. */ - void setResourceDirectory(String resourceDirectory); - + DatabaseBuilder setResourceDirectory(String resourceDirectory); /** * Add a custom type mapping. @@ -835,7 +853,7 @@ public interface DatabaseBuilder { * @param columnDefinition The column definition that should be used * @param platform Optionally specify the platform this mapping should apply to. */ - void addCustomMapping(DbType type, String columnDefinition, Platform platform); + DatabaseBuilder addCustomMapping(DbType type, String columnDefinition, Platform platform); /** * Add a custom type mapping that applies to all platforms. @@ -853,7 +871,7 @@ public interface DatabaseBuilder { * @param type The DB type this mapping should apply to * @param columnDefinition The column definition that should be used */ - void addCustomMapping(DbType type, String columnDefinition); + DatabaseBuilder addCustomMapping(DbType type, String columnDefinition); /** * Register a BeanQueryAdapter instance. @@ -861,7 +879,7 @@ public interface DatabaseBuilder { * Note alternatively you can use {@link #setQueryAdapters(List)} to set all * the BeanQueryAdapter instances. */ - void add(BeanQueryAdapter beanQueryAdapter); + DatabaseBuilder add(BeanQueryAdapter beanQueryAdapter); /** * Register all the BeanQueryAdapter instances. @@ -869,17 +887,17 @@ public interface DatabaseBuilder { * Note alternatively you can use {@link #add(BeanQueryAdapter)} to add * BeanQueryAdapter instances one at a time. */ - void setQueryAdapters(List queryAdapters); + DatabaseBuilder setQueryAdapters(List queryAdapters); /** * Set the custom IdGenerator instances. */ - void setIdGenerators(List idGenerators); + DatabaseBuilder setIdGenerators(List idGenerators); /** * Register a customer IdGenerator instance. */ - void add(IdGenerator idGenerator); + DatabaseBuilder add(IdGenerator idGenerator); /** * Register a BeanPersistController instance. @@ -887,7 +905,7 @@ public interface DatabaseBuilder { * Note alternatively you can use {@link #setPersistControllers(List)} to set * all the BeanPersistController instances. */ - void add(BeanPersistController beanPersistController); + DatabaseBuilder add(BeanPersistController beanPersistController); /** * Register a BeanPostLoad instance. @@ -895,7 +913,7 @@ public interface DatabaseBuilder { * Note alternatively you can use {@link #setPostLoaders(List)} to set * all the BeanPostLoad instances. */ - void add(BeanPostLoad postLoad); + DatabaseBuilder add(BeanPostLoad postLoad); /** * Register a BeanPostConstructListener instance. @@ -903,22 +921,22 @@ public interface DatabaseBuilder { * Note alternatively you can use {@link #setPostConstructListeners(List)} to set * all the BeanPostConstructListener instances. */ - void add(BeanPostConstructListener listener); + DatabaseBuilder add(BeanPostConstructListener listener); /** * Set the list of BeanFindController instances. */ - void setFindControllers(List findControllers); + DatabaseBuilder setFindControllers(List findControllers); /** * Set the list of BeanPostLoader instances. */ - void setPostLoaders(List postLoaders); + DatabaseBuilder setPostLoaders(List postLoaders); /** * Set the list of BeanPostLoader instances. */ - void setPostConstructListeners(List listeners); + DatabaseBuilder setPostConstructListeners(List listeners); /** * Register all the BeanPersistController instances. @@ -926,7 +944,7 @@ public interface DatabaseBuilder { * Note alternatively you can use {@link #add(BeanPersistController)} to add * BeanPersistController instances one at a time. */ - void setPersistControllers(List persistControllers); + DatabaseBuilder setPersistControllers(List persistControllers); /** * Register a BeanPersistListener instance. @@ -934,17 +952,17 @@ public interface DatabaseBuilder { * Note alternatively you can use {@link #setPersistListeners(List)} to set * all the BeanPersistListener instances. */ - void add(BeanPersistListener beanPersistListener); + DatabaseBuilder add(BeanPersistListener beanPersistListener); /** * Add a BulkTableEventListener */ - void add(BulkTableEventListener bulkTableEventListener); + DatabaseBuilder add(BulkTableEventListener bulkTableEventListener); /** * Add a ServerConfigStartup. */ - void addServerConfigStartup(ServerConfigStartup configStartupListener); + DatabaseBuilder addServerConfigStartup(ServerConfigStartup configStartupListener); /** * Register all the BeanPersistListener instances. @@ -952,7 +970,7 @@ public interface DatabaseBuilder { * Note alternatively you can use {@link #add(BeanPersistListener)} to add * BeanPersistListener instances one at a time. */ - void setPersistListeners(List persistListeners); + DatabaseBuilder setPersistListeners(List persistListeners); /** * Set the PersistenceContext scope to be used if one is not explicitly set on a query. @@ -965,13 +983,13 @@ public interface DatabaseBuilder { * * @see Query#setPersistenceContextScope(PersistenceContextScope) */ - void setPersistenceContextScope(PersistenceContextScope persistenceContextScope); + DatabaseBuilder setPersistenceContextScope(PersistenceContextScope persistenceContextScope); /** * Set the ClassLoadConfig which is used to detect Joda, Java8 types etc and also * create new instances of plugins given a className. */ - void setClassLoadConfig(ClassLoadConfig classLoadConfig); + DatabaseBuilder setClassLoadConfig(ClassLoadConfig classLoadConfig); /** * Load settings from application.properties, application.yaml and other sources. @@ -979,25 +997,19 @@ public interface DatabaseBuilder { * Uses avaje-config to load configuration properties. Goto https://avaje.io/config * for detail on how and where properties are loaded from. */ - void loadFromProperties(); + DatabaseBuilder loadFromProperties(); /** * Load the settings from the given properties */ - void loadFromProperties(Properties properties); - - /** - * Return the PersistBatch mode to use for 'batchOnCascade' taking into account if the database - * platform supports getGeneratedKeys in batch mode. - */ - PersistBatch appliedPersistBatchOnCascade(); + DatabaseBuilder loadFromProperties(Properties properties); /** * Set the Jackson ObjectMapper. *

    * Note that this is not strongly typed as Jackson ObjectMapper is an optional dependency. */ - void setObjectMapper(Object objectMapper); + DatabaseBuilder setObjectMapper(Object objectMapper); /** * Set to true if you want eq("someProperty", null) to generate "1=1" rather than "is null" sql expression. @@ -1006,27 +1018,27 @@ public interface DatabaseBuilder { * ne(propertyName, value) have no effect when the value is null. The expression factory adds a NoopExpression * which will add "1=1" into the SQL rather than "is null". */ - void setExpressionEqualsWithNullAsNoop(boolean expressionEqualsWithNullAsNoop); + DatabaseBuilder setExpressionEqualsWithNullAsNoop(boolean expressionEqualsWithNullAsNoop); /** * Set to true to use native ILIKE expression if supported by the database platform (e.g. Postgres). */ - void setExpressionNativeIlike(boolean expressionNativeIlike); + DatabaseBuilder setExpressionNativeIlike(boolean expressionNativeIlike); /** * Set the enabled L2 cache regions (comma delimited). */ - void setEnabledL2Regions(String enabledL2Regions); + DatabaseBuilder setEnabledL2Regions(String enabledL2Regions); /** * Set to true to disable L2 caching. Typically useful in performance testing. */ - void setDisableL2Cache(boolean disableL2Cache); + DatabaseBuilder setDisableL2Cache(boolean disableL2Cache); /** * Force the use of local only L2 cache. Effectively ignore l2 cache plugin like ebean-redis etc. */ - void setLocalOnlyL2Cache(boolean localOnlyL2Cache); + DatabaseBuilder setLocalOnlyL2Cache(boolean localOnlyL2Cache); /** * Controls if Ebean should ignore &x64;javax.validation.contstraints.NotNull or @@ -1037,7 +1049,7 @@ public interface DatabaseBuilder { * Set this to false and the javax NotNull annotation is effectively ignored (and * we instead use Ebean's own NotNull annotation or JPA Column(nullable=false) annotation. */ - void setUseValidationNotNull(boolean useValidationNotNull); + DatabaseBuilder setUseValidationNotNull(boolean useValidationNotNull); /** * Set this to true to run L2 cache notification in the foreground. @@ -1046,7 +1058,7 @@ public interface DatabaseBuilder { * we are making network calls and we prefer to do this in background and not impact the response time * of the executing transaction. */ - void setNotifyL2CacheInForeground(boolean notifyL2CacheInForeground); + DatabaseBuilder setNotifyL2CacheInForeground(boolean notifyL2CacheInForeground); /** * Set the time to live for ebean's internal query plan. @@ -1054,7 +1066,7 @@ public interface DatabaseBuilder { * This is the plan that knows how to execute the query, read the result * and collects execution metrics. By default this is set to 5 mins. */ - void setQueryPlanTTLSeconds(int queryPlanTTLSeconds); + DatabaseBuilder setQueryPlanTTLSeconds(int queryPlanTTLSeconds); /** * Create a new PlatformConfig based of the one held but with overridden properties by reading @@ -1072,25 +1084,25 @@ public interface DatabaseBuilder { /** * Add a mapping location to search for xml mapping via class path search. */ - void addMappingLocation(String mappingLocation); + DatabaseBuilder addMappingLocation(String mappingLocation); /** * Set mapping locations to search for xml mapping via class path search. *

    * This is only used if classes have not been explicitly specified. */ - void setMappingLocations(List mappingLocations); + DatabaseBuilder setMappingLocations(List mappingLocations); /** * Set to false such that Id properties require explicit @GeneratedValue * mapping before they are assigned Identity or Sequence generation based on platform. */ - void setIdGeneratorAutomatic(boolean idGeneratorAutomatic); + DatabaseBuilder setIdGeneratorAutomatic(boolean idGeneratorAutomatic); /** * Set to true to enable query plan capture. */ - void setQueryPlanEnable(boolean queryPlanEnable); + DatabaseBuilder setQueryPlanEnable(boolean queryPlanEnable); /** * Set the query plan collection threshold in microseconds. @@ -1098,17 +1110,17 @@ public interface DatabaseBuilder { * Queries executing slower than this will have bind values captured such that later * the query plan can be captured and reported. */ - void setQueryPlanThresholdMicros(long queryPlanThresholdMicros); + DatabaseBuilder setQueryPlanThresholdMicros(long queryPlanThresholdMicros); /** * Set to true to turn on periodic capture of query plans. */ - void setQueryPlanCapture(boolean queryPlanCapture); + DatabaseBuilder setQueryPlanCapture(boolean queryPlanCapture); /** * Set the frequency in seconds to capture query plans. */ - void setQueryPlanCapturePeriodSecs(long queryPlanCapturePeriodSecs); + DatabaseBuilder setQueryPlanCapturePeriodSecs(long queryPlanCapturePeriodSecs); /** * Set the time after which a capture query plans request will @@ -1117,49 +1129,43 @@ public interface DatabaseBuilder { * Effectively this controls the amount of load/time we want to * allow for query plan capture. */ - void setQueryPlanCaptureMaxTimeMillis(long queryPlanCaptureMaxTimeMillis); + DatabaseBuilder setQueryPlanCaptureMaxTimeMillis(long queryPlanCaptureMaxTimeMillis); /** * Set the max number of query plans captured per request. */ - void setQueryPlanCaptureMaxCount(int queryPlanCaptureMaxCount); + DatabaseBuilder setQueryPlanCaptureMaxCount(int queryPlanCaptureMaxCount); /** * Set the listener used to process captured query plans. */ - void setQueryPlanListener(QueryPlanListener queryPlanListener); + DatabaseBuilder setQueryPlanListener(QueryPlanListener queryPlanListener); /** * Set to true if metrics should be dumped when the server is shutdown. */ - void setDumpMetricsOnShutdown(boolean dumpMetricsOnShutdown); + DatabaseBuilder setDumpMetricsOnShutdown(boolean dumpMetricsOnShutdown); /** * Include 'sql' or 'hash' in options such that they are included in the output. * * @param dumpMetricsOptions Example "sql,hash", "sql" */ - void setDumpMetricsOptions(String dumpMetricsOptions); - - /** - * @deprecated - migrate to {@link Settings#isLoadModuleInfo()}. - */ - @Deprecated(forRemoval = true) - boolean isAutoLoadModuleInfo(); + DatabaseBuilder setDumpMetricsOptions(String dumpMetricsOptions); /** * Set false to turn off automatic registration of entity beans. *

    * When using query beans that also generates a module info class that - * can register the entity bean classes (to avoid classpath scanning). + * can register the entity bean classes (to aDatabaseBuilder classpath scanning). * This is on by default and setting this to false turns it off. */ - void setLoadModuleInfo(boolean loadModuleInfo); + DatabaseBuilder setLoadModuleInfo(boolean loadModuleInfo); /** * Set the naming convention to apply to metrics names. */ - void setMetricNaming(Function metricNaming); + DatabaseBuilder setMetricNaming(Function metricNaming); /** @@ -1168,6 +1174,12 @@ public interface DatabaseBuilder { */ interface Settings extends DatabaseBuilder { + /** + * @deprecated - migrate to {@link Settings#isLoadModuleInfo()}. + */ + @Deprecated(forRemoval = true) + boolean isAutoLoadModuleInfo(); + /** * Return the Jackson JsonFactory to use. *

    @@ -1387,6 +1399,11 @@ public interface DatabaseBuilder { */ ReadAuditPrepare getReadAuditPrepare(); + /** + * Return the tenancy catalog provider. + */ + TenantCatalogProvider getTenantCatalogProvider(); + /** * Return the configuration for profiling. */ @@ -1473,6 +1490,11 @@ public interface DatabaseBuilder { */ BackgroundExecutorWrapper getBackgroundExecutorWrapper(); + /** + * Return true if dirty beans are automatically persisted. + */ + boolean isAutoPersistUpdates(); + /** * Return the L2 cache default max size. */ @@ -1650,6 +1672,11 @@ public interface DatabaseBuilder { */ PlatformConfig getPlatformConfig(); + /** + * Return the PersistBatch mode to use for 'batchOnCascade' taking into account if the database + * platform supports getGeneratedKeys in batch mode. + */ + PersistBatch appliedPersistBatchOnCascade(); /** * Returns the UUID version mode. @@ -1719,6 +1746,11 @@ public interface DatabaseBuilder { */ boolean isDdlExtra(); + /** + * Return true if strict mode is used which includes a check that non-null columns have a default value. + */ + boolean isDdlStrictMode(); + /** * Return the header to use with DDL generation. */ 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 8d9e4c03e..f7c633681 100644 --- a/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java +++ b/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java @@ -3,7 +3,9 @@ package io.ebean.config; import com.fasterxml.jackson.core.JsonFactory; import io.avaje.config.Config; import io.ebean.*; -import io.ebean.annotation.*; +import io.ebean.annotation.MutationDetection; +import io.ebean.annotation.PersistBatch; +import io.ebean.annotation.Platform; import io.ebean.cache.ServerCachePlugin; import io.ebean.config.dbplatform.DatabasePlatform; import io.ebean.config.dbplatform.DbEncrypt; @@ -18,8 +20,8 @@ import io.ebean.event.readaudit.ReadAuditLogger; import io.ebean.event.readaudit.ReadAuditPrepare; import io.ebean.meta.MetricNamingMatch; import io.ebean.util.StringHelper; - import jakarta.persistence.EnumType; + import javax.sql.DataSource; import java.time.Clock; import java.time.ZonedDateTime; @@ -548,6 +550,11 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { public DatabaseConfig() { } + @Override + public Database build() { + return DatabaseFactory.create(this); + } + @Override public Settings settings() { return this; @@ -559,8 +566,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setClock(final Clock clock) { + public DatabaseConfig setClock(final Clock clock) { this.clock = clock; + return this; } @Override @@ -569,8 +577,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setSlowQueryMillis(long slowQueryMillis) { + public DatabaseConfig setSlowQueryMillis(long slowQueryMillis) { this.slowQueryMillis = slowQueryMillis; + return this; } @Override @@ -579,18 +588,21 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setSlowQueryListener(SlowQueryListener slowQueryListener) { + public DatabaseConfig setSlowQueryListener(SlowQueryListener slowQueryListener) { this.slowQueryListener = slowQueryListener; + return this; } @Override - public void putServiceObject(String key, Object configObject) { + public DatabaseConfig putServiceObject(String key, Object configObject) { serviceObject.put(key, configObject); + return this; } @Override - public void putServiceObject(Class iface, T configObject) { + public DatabaseConfig putServiceObject(Class iface, T configObject) { serviceObject.put(serviceObjectKey(iface), configObject); + return this; } @Override @@ -599,9 +611,10 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void putServiceObject(Object configObject) { + public DatabaseConfig putServiceObject(Object configObject) { String key = serviceObjectKey(configObject); serviceObject.put(key, configObject); + return this; } @Override @@ -625,8 +638,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setJsonFactory(JsonFactory jsonFactory) { + public DatabaseConfig setJsonFactory(JsonFactory jsonFactory) { this.jsonFactory = jsonFactory; + return this; } @Override @@ -635,8 +649,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setJsonDateTime(JsonConfig.DateTime jsonDateTime) { + public DatabaseConfig setJsonDateTime(JsonConfig.DateTime jsonDateTime) { this.jsonDateTime = jsonDateTime; + return this; } @Override @@ -645,8 +660,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setJsonDate(JsonConfig.Date jsonDate) { + public DatabaseConfig setJsonDate(JsonConfig.Date jsonDate) { this.jsonDate = jsonDate; + return this; } @Override @@ -655,8 +671,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setJsonInclude(JsonConfig.Include jsonInclude) { + public DatabaseConfig setJsonInclude(JsonConfig.Include jsonInclude) { this.jsonInclude = jsonInclude; + return this; } @Override @@ -665,8 +682,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setJsonMutationDetection(MutationDetection jsonMutationDetection) { + public DatabaseConfig setJsonMutationDetection(MutationDetection jsonMutationDetection) { this.jsonMutationDetection = jsonMutationDetection; + return this; } @Override @@ -675,8 +693,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setName(String name) { + public DatabaseConfig setName(String name) { this.name = name; + return this; } @Override @@ -685,8 +704,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setContainerConfig(ContainerConfig containerConfig) { + public DatabaseConfig setContainerConfig(ContainerConfig containerConfig) { this.containerConfig = containerConfig; + return this; } @Override @@ -695,8 +715,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setRegister(boolean register) { + public DatabaseConfig setRegister(boolean register) { this.register = register; + return this; } @Override @@ -705,8 +726,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setDefaultServer(boolean defaultServer) { + public DatabaseConfig setDefaultServer(boolean defaultServer) { this.defaultServer = defaultServer; + return this; } @Override @@ -715,8 +737,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setCurrentUserProvider(CurrentUserProvider currentUserProvider) { + public DatabaseConfig setCurrentUserProvider(CurrentUserProvider currentUserProvider) { this.currentUserProvider = currentUserProvider; + return this; } @Override @@ -725,8 +748,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setTenantMode(TenantMode tenantMode) { + public DatabaseConfig setTenantMode(TenantMode tenantMode) { this.tenantMode = tenantMode; + return this; } @Override @@ -735,8 +759,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setTenantPartitionColumn(String tenantPartitionColumn) { + public DatabaseConfig setTenantPartitionColumn(String tenantPartitionColumn) { this.tenantPartitionColumn = tenantPartitionColumn; + return this; } @Override @@ -745,8 +770,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setCurrentTenantProvider(CurrentTenantProvider currentTenantProvider) { + public DatabaseConfig setCurrentTenantProvider(CurrentTenantProvider currentTenantProvider) { this.currentTenantProvider = currentTenantProvider; + return this; } @Override @@ -755,8 +781,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setTenantDataSourceProvider(TenantDataSourceProvider tenantDataSourceProvider) { + public DatabaseConfig setTenantDataSourceProvider(TenantDataSourceProvider tenantDataSourceProvider) { this.tenantDataSourceProvider = tenantDataSourceProvider; + return this; } @Override @@ -765,8 +792,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setTenantSchemaProvider(TenantSchemaProvider tenantSchemaProvider) { + public DatabaseConfig setTenantSchemaProvider(TenantSchemaProvider tenantSchemaProvider) { this.tenantSchemaProvider = tenantSchemaProvider; + return this; } @Override @@ -775,8 +803,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setTenantCatalogProvider(TenantCatalogProvider tenantCatalogProvider) { + public DatabaseConfig setTenantCatalogProvider(TenantCatalogProvider tenantCatalogProvider) { this.tenantCatalogProvider = tenantCatalogProvider; + return this; } @Override @@ -785,8 +814,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setAutoPersistUpdates(boolean autoPersistUpdates) { + public DatabaseConfig setAutoPersistUpdates(boolean autoPersistUpdates) { this.autoPersistUpdates = autoPersistUpdates; + return this; } @Override @@ -795,8 +825,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setPersistBatch(PersistBatch persistBatch) { + public DatabaseConfig setPersistBatch(PersistBatch persistBatch) { this.persistBatch = persistBatch; + return this; } @Override @@ -805,13 +836,15 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setPersistBatchOnCascade(PersistBatch persistBatchOnCascade) { + public DatabaseConfig setPersistBatchOnCascade(PersistBatch persistBatchOnCascade) { this.persistBatchOnCascade = persistBatchOnCascade; + return this; } @Override - public void setPersistBatching(boolean persistBatching) { + public DatabaseConfig setPersistBatching(boolean persistBatching) { this.persistBatch = (persistBatching) ? PersistBatch.ALL : PersistBatch.NONE; + return this; } @Override @@ -820,8 +853,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setPersistBatchSize(int persistBatchSize) { + public DatabaseConfig setPersistBatchSize(int persistBatchSize) { this.persistBatchSize = persistBatchSize; + return this; } @Override @@ -830,8 +864,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setQueryBatchSize(int queryBatchSize) { + public DatabaseConfig setQueryBatchSize(int queryBatchSize) { this.queryBatchSize = queryBatchSize; + return this; } @Override @@ -840,8 +875,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setDefaultEnumType(EnumType defaultEnumType) { + public DatabaseConfig setDefaultEnumType(EnumType defaultEnumType) { this.defaultEnumType = defaultEnumType; + return this; } @Override @@ -850,8 +886,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setDisableLazyLoading(boolean disableLazyLoading) { + public DatabaseConfig setDisableLazyLoading(boolean disableLazyLoading) { this.disableLazyLoading = disableLazyLoading; + return this; } @Override @@ -860,13 +897,15 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setLazyLoadBatchSize(int lazyLoadBatchSize) { + public DatabaseConfig setLazyLoadBatchSize(int lazyLoadBatchSize) { this.lazyLoadBatchSize = lazyLoadBatchSize; + return this; } @Override - public void setDatabaseSequenceBatchSize(int databaseSequenceBatchSize) { + public DatabaseConfig setDatabaseSequenceBatchSize(int databaseSequenceBatchSize) { platformConfig.setDatabaseSequenceBatchSize(databaseSequenceBatchSize); + return this; } @Override @@ -875,8 +914,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setJdbcFetchSizeFindList(int jdbcFetchSizeFindList) { + public DatabaseConfig setJdbcFetchSizeFindList(int jdbcFetchSizeFindList) { this.jdbcFetchSizeFindList = jdbcFetchSizeFindList; + return this; } @Override @@ -885,8 +925,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setJdbcFetchSizeFindEach(int jdbcFetchSizeFindEach) { + public DatabaseConfig setJdbcFetchSizeFindEach(int jdbcFetchSizeFindEach) { this.jdbcFetchSizeFindEach = jdbcFetchSizeFindEach; + return this; } @Override @@ -895,8 +936,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setChangeLogPrepare(ChangeLogPrepare changeLogPrepare) { + public DatabaseConfig setChangeLogPrepare(ChangeLogPrepare changeLogPrepare) { this.changeLogPrepare = changeLogPrepare; + return this; } @Override @@ -905,8 +947,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setChangeLogListener(ChangeLogListener changeLogListener) { + public DatabaseConfig setChangeLogListener(ChangeLogListener changeLogListener) { this.changeLogListener = changeLogListener; + return this; } @Override @@ -915,8 +958,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setChangeLogRegister(ChangeLogRegister changeLogRegister) { + public DatabaseConfig setChangeLogRegister(ChangeLogRegister changeLogRegister) { this.changeLogRegister = changeLogRegister; + return this; } @Override @@ -925,8 +969,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setChangeLogIncludeInserts(boolean changeLogIncludeInserts) { + public DatabaseConfig setChangeLogIncludeInserts(boolean changeLogIncludeInserts) { this.changeLogIncludeInserts = changeLogIncludeInserts; + return this; } @Override @@ -935,8 +980,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setChangeLogAsync(boolean changeLogAsync) { + public DatabaseConfig setChangeLogAsync(boolean changeLogAsync) { this.changeLogAsync = changeLogAsync; + return this; } @Override @@ -945,8 +991,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setReadAuditLogger(ReadAuditLogger readAuditLogger) { + public DatabaseConfig setReadAuditLogger(ReadAuditLogger readAuditLogger) { this.readAuditLogger = readAuditLogger; + return this; } @Override @@ -955,8 +1002,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setReadAuditPrepare(ReadAuditPrepare readAuditPrepare) { + public DatabaseConfig setReadAuditPrepare(ReadAuditPrepare readAuditPrepare) { this.readAuditPrepare = readAuditPrepare; + return this; } @Override @@ -965,8 +1013,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setProfilingConfig(ProfilingConfig profilingConfig) { + public DatabaseConfig setProfilingConfig(ProfilingConfig profilingConfig) { this.profilingConfig = profilingConfig; + return this; } @Override @@ -975,8 +1024,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setDbSchema(String dbSchema) { + public DatabaseConfig setDbSchema(String dbSchema) { this.dbSchema = dbSchema; + return this; } @Override @@ -985,8 +1035,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setGeometrySRID(int geometrySRID) { + public DatabaseConfig setGeometrySRID(int geometrySRID) { platformConfig.setGeometrySRID(geometrySRID); + return this; } @Override @@ -995,8 +1046,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setDataTimeZone(String dataTimeZone) { + public DatabaseConfig setDataTimeZone(String dataTimeZone) { this.dataTimeZone = dataTimeZone; + return this; } @Override @@ -1005,8 +1057,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setAsOfViewSuffix(String asOfViewSuffix) { + public DatabaseConfig setAsOfViewSuffix(String asOfViewSuffix) { this.asOfViewSuffix = asOfViewSuffix; + return this; } @Override @@ -1015,8 +1068,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setAsOfSysPeriod(String asOfSysPeriod) { + public DatabaseConfig setAsOfSysPeriod(String asOfSysPeriod) { this.asOfSysPeriod = asOfSysPeriod; + return this; } @Override @@ -1025,8 +1079,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setHistoryTableSuffix(String historyTableSuffix) { + public DatabaseConfig setHistoryTableSuffix(String historyTableSuffix) { this.historyTableSuffix = historyTableSuffix; + return this; } @Override @@ -1035,8 +1090,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setUseJtaTransactionManager(boolean useJtaTransactionManager) { + public DatabaseConfig setUseJtaTransactionManager(boolean useJtaTransactionManager) { this.useJtaTransactionManager = useJtaTransactionManager; + return this; } @Override @@ -1045,8 +1101,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setExternalTransactionManager(ExternalTransactionManager externalTransactionManager) { + public DatabaseConfig setExternalTransactionManager(ExternalTransactionManager externalTransactionManager) { this.externalTransactionManager = externalTransactionManager; + return this; } @Override @@ -1055,8 +1112,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setServerCachePlugin(ServerCachePlugin serverCachePlugin) { + public DatabaseConfig setServerCachePlugin(ServerCachePlugin serverCachePlugin) { this.serverCachePlugin = serverCachePlugin; + return this; } @Override @@ -1065,8 +1123,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setEagerFetchLobs(boolean eagerFetchLobs) { + public DatabaseConfig setEagerFetchLobs(boolean eagerFetchLobs) { this.eagerFetchLobs = eagerFetchLobs; + return this; } @Override @@ -1075,8 +1134,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setMaxCallStack(int maxCallStack) { + public DatabaseConfig setMaxCallStack(int maxCallStack) { this.maxCallStack = maxCallStack; + return this; } @Override @@ -1085,8 +1145,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setTransactionRollbackOnChecked(boolean transactionRollbackOnChecked) { + public DatabaseConfig setTransactionRollbackOnChecked(boolean transactionRollbackOnChecked) { this.transactionRollbackOnChecked = transactionRollbackOnChecked; + return this; } @Override @@ -1095,8 +1156,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setBackgroundExecutorSchedulePoolSize(int backgroundExecutorSchedulePoolSize) { + public DatabaseConfig setBackgroundExecutorSchedulePoolSize(int backgroundExecutorSchedulePoolSize) { this.backgroundExecutorSchedulePoolSize = backgroundExecutorSchedulePoolSize; + return this; } @Override @@ -1105,8 +1167,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setBackgroundExecutorShutdownSecs(int backgroundExecutorShutdownSecs) { + public DatabaseConfig setBackgroundExecutorShutdownSecs(int backgroundExecutorShutdownSecs) { this.backgroundExecutorShutdownSecs = backgroundExecutorShutdownSecs; + return this; } @Override @@ -1115,8 +1178,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setBackgroundExecutorWrapper(BackgroundExecutorWrapper backgroundExecutorWrapper) { + public DatabaseConfig setBackgroundExecutorWrapper(BackgroundExecutorWrapper backgroundExecutorWrapper) { this.backgroundExecutorWrapper = backgroundExecutorWrapper; + return this; } @Override @@ -1125,8 +1189,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setCacheMaxSize(int cacheMaxSize) { + public DatabaseConfig setCacheMaxSize(int cacheMaxSize) { this.cacheMaxSize = cacheMaxSize; + return this; } @Override @@ -1135,8 +1200,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setCacheMaxIdleTime(int cacheMaxIdleTime) { + public DatabaseConfig setCacheMaxIdleTime(int cacheMaxIdleTime) { this.cacheMaxIdleTime = cacheMaxIdleTime; + return this; } @Override @@ -1145,8 +1211,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setCacheMaxTimeToLive(int cacheMaxTimeToLive) { + public DatabaseConfig setCacheMaxTimeToLive(int cacheMaxTimeToLive) { this.cacheMaxTimeToLive = cacheMaxTimeToLive; + return this; } @Override @@ -1155,8 +1222,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setQueryCacheMaxSize(int queryCacheMaxSize) { + public DatabaseConfig setQueryCacheMaxSize(int queryCacheMaxSize) { this.queryCacheMaxSize = queryCacheMaxSize; + return this; } @Override @@ -1165,8 +1233,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setQueryCacheMaxIdleTime(int queryCacheMaxIdleTime) { + public DatabaseConfig setQueryCacheMaxIdleTime(int queryCacheMaxIdleTime) { this.queryCacheMaxIdleTime = queryCacheMaxIdleTime; + return this; } @Override @@ -1175,8 +1244,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setQueryCacheMaxTimeToLive(int queryCacheMaxTimeToLive) { + public DatabaseConfig setQueryCacheMaxTimeToLive(int queryCacheMaxTimeToLive) { this.queryCacheMaxTimeToLive = queryCacheMaxTimeToLive; + return this; } @Override @@ -1185,8 +1255,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setNamingConvention(NamingConvention namingConvention) { + public DatabaseConfig setNamingConvention(NamingConvention namingConvention) { this.namingConvention = namingConvention; + return this; } @Override @@ -1195,11 +1266,12 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setAllQuotedIdentifiers(boolean allQuotedIdentifiers) { + public DatabaseConfig setAllQuotedIdentifiers(boolean allQuotedIdentifiers) { platformConfig.setAllQuotedIdentifiers(allQuotedIdentifiers); if (allQuotedIdentifiers) { adjustNamingConventionForAllQuoted(); } + return this; } private void adjustNamingConventionForAllQuoted() { @@ -1215,8 +1287,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setDocStoreOnly(boolean docStoreOnly) { + public DatabaseConfig setDocStoreOnly(boolean docStoreOnly) { this.docStoreOnly = docStoreOnly; + return this; } @Override @@ -1225,8 +1298,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setDocStoreConfig(DocStoreConfig docStoreConfig) { + public DatabaseConfig setDocStoreConfig(DocStoreConfig docStoreConfig) { this.docStoreConfig = docStoreConfig; + return this; } @Override @@ -1235,8 +1309,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setConstraintNaming(DbConstraintNaming constraintNaming) { + public DatabaseConfig setConstraintNaming(DbConstraintNaming constraintNaming) { platformConfig.setConstraintNaming(constraintNaming); + return this; } @Override @@ -1245,8 +1320,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setAutoTuneConfig(AutoTuneConfig autoTuneConfig) { + public DatabaseConfig setAutoTuneConfig(AutoTuneConfig autoTuneConfig) { this.autoTuneConfig = autoTuneConfig; + return this; } @Override @@ -1255,8 +1331,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setSkipDataSourceCheck(boolean skipDataSourceCheck) { + public DatabaseConfig setSkipDataSourceCheck(boolean skipDataSourceCheck) { this.skipDataSourceCheck = skipDataSourceCheck; + return this; } @Override @@ -1265,8 +1342,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setDataSource(DataSource dataSource) { + public DatabaseConfig setDataSource(DataSource dataSource) { this.dataSource = dataSource; + return this; } @Override @@ -1275,8 +1353,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setReadOnlyDataSource(DataSource readOnlyDataSource) { + public DatabaseConfig setReadOnlyDataSource(DataSource readOnlyDataSource) { this.readOnlyDataSource = readOnlyDataSource; + return this; } @Override @@ -1285,8 +1364,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setDataSourceConfig(DataSourceBuilder dataSourceConfig) { + public DatabaseConfig setDataSourceConfig(DataSourceBuilder dataSourceConfig) { this.dataSourceConfig = dataSourceConfig; + return this; } @Override @@ -1295,8 +1375,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setAutoReadOnlyDataSource(boolean autoReadOnlyDataSource) { + public DatabaseConfig setAutoReadOnlyDataSource(boolean autoReadOnlyDataSource) { this.autoReadOnlyDataSource = autoReadOnlyDataSource; + return this; } @Override @@ -1305,8 +1386,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setReadOnlyDataSourceConfig(DataSourceBuilder readOnlyDataSourceConfig) { + public DatabaseConfig setReadOnlyDataSourceConfig(DataSourceBuilder readOnlyDataSourceConfig) { this.readOnlyDataSourceConfig = readOnlyDataSourceConfig; + return this; } @Override @@ -1315,8 +1397,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setDatabaseBooleanTrue(String databaseTrue) { + public DatabaseConfig setDatabaseBooleanTrue(String databaseTrue) { platformConfig.setDatabaseBooleanTrue(databaseTrue); + return this; } @Override @@ -1325,8 +1408,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setDatabaseBooleanFalse(String databaseFalse) { + public DatabaseConfig setDatabaseBooleanFalse(String databaseFalse) { this.platformConfig.setDatabaseBooleanFalse(databaseFalse); + return this; } @Override @@ -1335,8 +1419,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setDatabaseSequenceBatch(int databaseSequenceBatchSize) { + public DatabaseConfig setDatabaseSequenceBatch(int databaseSequenceBatchSize) { this.platformConfig.setDatabaseSequenceBatchSize(databaseSequenceBatchSize); + return this; } @Override @@ -1345,8 +1430,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setDatabasePlatformName(String databasePlatformName) { + public DatabaseConfig setDatabasePlatformName(String databasePlatformName) { this.databasePlatformName = databasePlatformName; + return this; } @Override @@ -1355,8 +1441,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setDatabasePlatform(DatabasePlatform databasePlatform) { + public DatabaseConfig setDatabasePlatform(DatabasePlatform databasePlatform) { this.databasePlatform = databasePlatform; + return this; } @Override @@ -1365,8 +1452,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setIdType(IdType idType) { + public DatabaseConfig setIdType(IdType idType) { this.platformConfig.setIdType(idType); + return this; } @Override @@ -1375,8 +1463,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setEncryptKeyManager(EncryptKeyManager encryptKeyManager) { + public DatabaseConfig setEncryptKeyManager(EncryptKeyManager encryptKeyManager) { this.encryptKeyManager = encryptKeyManager; + return this; } @Override @@ -1385,8 +1474,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setEncryptDeployManager(EncryptDeployManager encryptDeployManager) { + public DatabaseConfig setEncryptDeployManager(EncryptDeployManager encryptDeployManager) { this.encryptDeployManager = encryptDeployManager; + return this; } @Override @@ -1395,8 +1485,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setEncryptor(Encryptor encryptor) { + public DatabaseConfig setEncryptor(Encryptor encryptor) { this.encryptor = encryptor; + return this; } @Override @@ -1405,8 +1496,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setDbOffline(boolean dbOffline) { + public DatabaseConfig setDbOffline(boolean dbOffline) { this.dbOffline = dbOffline; + return this; } @Override @@ -1415,8 +1507,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setDbEncrypt(DbEncrypt dbEncrypt) { + public DatabaseConfig setDbEncrypt(DbEncrypt dbEncrypt) { this.dbEncrypt = dbEncrypt; + return this; } @Override @@ -1425,13 +1518,15 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setPlatformConfig(PlatformConfig platformConfig) { + public DatabaseConfig setPlatformConfig(PlatformConfig platformConfig) { this.platformConfig = platformConfig; + return this; } @Override - public void setDbUuid(PlatformConfig.DbUuid dbUuid) { + public DatabaseConfig setDbUuid(PlatformConfig.DbUuid dbUuid) { this.platformConfig.setDbUuid(dbUuid); + return this; } @Override @@ -1440,8 +1535,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setUuidVersion(UuidVersion uuidVersion) { + public DatabaseConfig setUuidVersion(UuidVersion uuidVersion) { this.uuidVersion = uuidVersion; + return this; } @Override @@ -1459,8 +1555,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setUuidStateFile(String uuidStateFile) { + public DatabaseConfig setUuidStateFile(String uuidStateFile) { this.uuidStateFile = uuidStateFile; + return this; } @Override @@ -1469,8 +1566,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setUuidNodeId(String uuidNodeId) { + public DatabaseConfig setUuidNodeId(String uuidNodeId) { this.uuidNodeId = uuidNodeId; + return this; } @Override @@ -1479,8 +1577,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setLocalTimeWithNanos(boolean localTimeWithNanos) { + public DatabaseConfig setLocalTimeWithNanos(boolean localTimeWithNanos) { this.localTimeWithNanos = localTimeWithNanos; + return this; } @Override @@ -1489,13 +1588,15 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setDurationWithNanos(boolean durationWithNanos) { + public DatabaseConfig setDurationWithNanos(boolean durationWithNanos) { this.durationWithNanos = durationWithNanos; + return this; } @Override - public void setRunMigration(boolean runMigration) { + public DatabaseConfig setRunMigration(boolean runMigration) { this.runMigration = runMigration; + return this; } @Override @@ -1505,18 +1606,21 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setDdlGenerate(boolean ddlGenerate) { + public DatabaseConfig setDdlGenerate(boolean ddlGenerate) { this.ddlGenerate = ddlGenerate; + return this; } @Override - public void setDdlRun(boolean ddlRun) { + public DatabaseConfig setDdlRun(boolean ddlRun) { this.ddlRun = ddlRun; + return this; } @Override - public void setDdlExtra(boolean ddlExtra) { + public DatabaseConfig setDdlExtra(boolean ddlExtra) { this.ddlExtra = ddlExtra; + return this; } @@ -1526,8 +1630,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setDdlCreateOnly(boolean ddlCreateOnly) { + public DatabaseConfig setDdlCreateOnly(boolean ddlCreateOnly) { this.ddlCreateOnly = ddlCreateOnly; + return this; } @Override @@ -1536,8 +1641,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setDdlSeedSql(String ddlSeedSql) { + public DatabaseConfig setDdlSeedSql(String ddlSeedSql) { this.ddlSeedSql = ddlSeedSql; + return this; } @Override @@ -1546,8 +1652,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setDdlInitSql(String ddlInitSql) { + public DatabaseConfig setDdlInitSql(String ddlInitSql) { this.ddlInitSql = ddlInitSql; + return this; } @Override @@ -1566,8 +1673,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setDdlHeader(String ddlHeader) { + public DatabaseConfig setDdlHeader(String ddlHeader) { this.ddlHeader = ddlHeader; + return this; } @Override @@ -1586,8 +1694,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setDdlStrictMode(boolean ddlStrictMode) { + public DatabaseConfig setDdlStrictMode(boolean ddlStrictMode) { this.ddlStrictMode = ddlStrictMode; + return this; } @Override @@ -1596,8 +1705,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setDdlPlaceholders(String ddlPlaceholders) { + public DatabaseConfig setDdlPlaceholders(String ddlPlaceholders) { this.ddlPlaceholders = ddlPlaceholders; + return this; } @Override @@ -1606,8 +1716,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setDdlPlaceholderMap(Map ddlPlaceholderMap) { + public DatabaseConfig setDdlPlaceholderMap(Map ddlPlaceholderMap) { this.ddlPlaceholderMap = ddlPlaceholderMap; + return this; } @Override @@ -1616,8 +1727,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setDisableClasspathSearch(boolean disableClasspathSearch) { + public DatabaseConfig setDisableClasspathSearch(boolean disableClasspathSearch) { this.disableClasspathSearch = disableClasspathSearch; + return this; } @Override @@ -1626,25 +1738,29 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setJodaLocalTimeMode(String jodaLocalTimeMode) { + public DatabaseConfig setJodaLocalTimeMode(String jodaLocalTimeMode) { this.jodaLocalTimeMode = jodaLocalTimeMode; + return this; } @Override - public void addClass(Class cls) { + public DatabaseConfig addClass(Class cls) { classes.add(cls); + return this; } @Override - public void addAll(Collection> classList) { + public DatabaseConfig addAll(Collection> classList) { if (classList != null && !classList.isEmpty()) { classes.addAll(classList); } + return this; } @Override - public void addPackage(String packageName) { + public DatabaseConfig addPackage(String packageName) { packages.add(packageName); + return this; } @Override @@ -1653,13 +1769,25 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setPackages(List packages) { + public DatabaseConfig setPackages(List packages) { this.packages = packages; + return this; + } + + /** + * Set the list of classes (entities, listeners, scalarTypes etc) that should + * be used for this database. + *

    + * Leaving void for spring xml wiring for now. + */ + public void setClasses(Collection> classes) { + this.classes = new HashSet<>(classes); } @Override - public void setClasses(Collection> classes) { + public DatabaseConfig classes(Collection> classes) { this.classes = new HashSet<>(classes); + return this; } @Override @@ -1683,8 +1811,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setSkipCacheAfterWrite(boolean skipCacheAfterWrite) { + public DatabaseConfig setSkipCacheAfterWrite(boolean skipCacheAfterWrite) { this.skipCacheAfterWrite = skipCacheAfterWrite; + return this; } @Override @@ -1693,8 +1822,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setUpdateAllPropertiesInBatch(boolean updateAllPropertiesInBatch) { + public DatabaseConfig setUpdateAllPropertiesInBatch(boolean updateAllPropertiesInBatch) { this.updateAllPropertiesInBatch = updateAllPropertiesInBatch; + return this; } @Override @@ -1703,23 +1833,27 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setResourceDirectory(String resourceDirectory) { + public DatabaseConfig setResourceDirectory(String resourceDirectory) { this.resourceDirectory = resourceDirectory; + return this; } @Override - public void addCustomMapping(DbType type, String columnDefinition, Platform platform) { + public DatabaseConfig addCustomMapping(DbType type, String columnDefinition, Platform platform) { platformConfig.addCustomMapping(type, columnDefinition, platform); + return this; } @Override - public void addCustomMapping(DbType type, String columnDefinition) { + public DatabaseConfig addCustomMapping(DbType type, String columnDefinition) { platformConfig.addCustomMapping(type, columnDefinition); + return this; } @Override - public void add(BeanQueryAdapter beanQueryAdapter) { + public DatabaseConfig add(BeanQueryAdapter beanQueryAdapter) { queryAdapters.add(beanQueryAdapter); + return this; } @Override @@ -1728,8 +1862,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setQueryAdapters(List queryAdapters) { + public DatabaseConfig setQueryAdapters(List queryAdapters) { this.queryAdapters = queryAdapters; + return this; } @Override @@ -1738,28 +1873,33 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setIdGenerators(List idGenerators) { + public DatabaseConfig setIdGenerators(List idGenerators) { this.idGenerators = idGenerators; + return this; } @Override - public void add(IdGenerator idGenerator) { + public DatabaseConfig add(IdGenerator idGenerator) { idGenerators.add(idGenerator); + return this; } @Override - public void add(BeanPersistController beanPersistController) { + public DatabaseConfig add(BeanPersistController beanPersistController) { persistControllers.add(beanPersistController); + return this; } @Override - public void add(BeanPostLoad postLoad) { + public DatabaseConfig add(BeanPostLoad postLoad) { postLoaders.add(postLoad); + return this; } @Override - public void add(BeanPostConstructListener listener) { + public DatabaseConfig add(BeanPostConstructListener listener) { postConstructListeners.add(listener); + return this; } @Override @@ -1768,8 +1908,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setFindControllers(List findControllers) { + public DatabaseConfig setFindControllers(List findControllers) { this.findControllers = findControllers; + return this; } @Override @@ -1778,8 +1919,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setPostLoaders(List postLoaders) { + public DatabaseConfig setPostLoaders(List postLoaders) { this.postLoaders = postLoaders; + return this; } @Override @@ -1788,8 +1930,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setPostConstructListeners(List listeners) { + public DatabaseConfig setPostConstructListeners(List listeners) { this.postConstructListeners = listeners; + return this; } @Override @@ -1798,13 +1941,15 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setPersistControllers(List persistControllers) { + public DatabaseConfig setPersistControllers(List persistControllers) { this.persistControllers = persistControllers; + return this; } @Override - public void add(BeanPersistListener beanPersistListener) { + public DatabaseConfig add(BeanPersistListener beanPersistListener) { persistListeners.add(beanPersistListener); + return this; } @Override @@ -1813,8 +1958,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void add(BulkTableEventListener bulkTableEventListener) { + public DatabaseConfig add(BulkTableEventListener bulkTableEventListener) { bulkTableEventListeners.add(bulkTableEventListener); + return this; } @Override @@ -1823,8 +1969,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void addServerConfigStartup(ServerConfigStartup configStartupListener) { + public DatabaseConfig addServerConfigStartup(ServerConfigStartup configStartupListener) { configStartupListeners.add(configStartupListener); + return this; } @Override @@ -1833,8 +1980,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setPersistListeners(List persistListeners) { + public DatabaseConfig setPersistListeners(List persistListeners) { this.persistListeners = persistListeners; + return this; } @Override @@ -1844,8 +1992,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setPersistenceContextScope(PersistenceContextScope persistenceContextScope) { + public DatabaseConfig setPersistenceContextScope(PersistenceContextScope persistenceContextScope) { this.persistenceContextScope = persistenceContextScope; + return this; } @Override @@ -1854,21 +2003,24 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setClassLoadConfig(ClassLoadConfig classLoadConfig) { + public DatabaseConfig setClassLoadConfig(ClassLoadConfig classLoadConfig) { this.classLoadConfig = classLoadConfig; + return this; } @Override - public void loadFromProperties() { + public DatabaseConfig loadFromProperties() { this.properties = Config.asProperties(); configureFromProperties(); + return this; } @Override - public void loadFromProperties(Properties properties) { + public DatabaseConfig loadFromProperties(Properties properties) { // keep the properties used for configuration so that these are available for plugins this.properties = Config.asConfiguration().eval(properties); configureFromProperties(); + return this; } /** @@ -2132,8 +2284,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setObjectMapper(Object objectMapper) { + public DatabaseConfig setObjectMapper(Object objectMapper) { this.objectMapper = objectMapper; + return this; } @Override @@ -2142,8 +2295,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setExpressionEqualsWithNullAsNoop(boolean expressionEqualsWithNullAsNoop) { + public DatabaseConfig setExpressionEqualsWithNullAsNoop(boolean expressionEqualsWithNullAsNoop) { this.expressionEqualsWithNullAsNoop = expressionEqualsWithNullAsNoop; + return this; } @Override @@ -2152,8 +2306,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setExpressionNativeIlike(boolean expressionNativeIlike) { + public DatabaseConfig setExpressionNativeIlike(boolean expressionNativeIlike) { this.expressionNativeIlike = expressionNativeIlike; + return this; } @Override @@ -2162,8 +2317,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setEnabledL2Regions(String enabledL2Regions) { + public DatabaseConfig setEnabledL2Regions(String enabledL2Regions) { this.enabledL2Regions = enabledL2Regions; + return this; } @Override @@ -2172,8 +2328,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setDisableL2Cache(boolean disableL2Cache) { + public DatabaseConfig setDisableL2Cache(boolean disableL2Cache) { this.disableL2Cache = disableL2Cache; + return this; } @Override @@ -2182,8 +2339,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setLocalOnlyL2Cache(boolean localOnlyL2Cache) { + public DatabaseConfig setLocalOnlyL2Cache(boolean localOnlyL2Cache) { this.localOnlyL2Cache = localOnlyL2Cache; + return this; } @Override @@ -2192,8 +2350,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setUseValidationNotNull(boolean useValidationNotNull) { + public DatabaseConfig setUseValidationNotNull(boolean useValidationNotNull) { this.useValidationNotNull = useValidationNotNull; + return this; } @Override @@ -2202,8 +2361,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setNotifyL2CacheInForeground(boolean notifyL2CacheInForeground) { + public DatabaseConfig setNotifyL2CacheInForeground(boolean notifyL2CacheInForeground) { this.notifyL2CacheInForeground = notifyL2CacheInForeground; + return this; } @Override @@ -2212,8 +2372,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setQueryPlanTTLSeconds(int queryPlanTTLSeconds) { + public DatabaseConfig setQueryPlanTTLSeconds(int queryPlanTTLSeconds) { this.queryPlanTTLSeconds = queryPlanTTLSeconds; + return this; } @Override @@ -2228,11 +2389,12 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void addMappingLocation(String mappingLocation) { + public DatabaseConfig addMappingLocation(String mappingLocation) { if (mappingLocations == null) { mappingLocations = new ArrayList<>(); } mappingLocations.add(mappingLocation); + return this; } @Override @@ -2241,8 +2403,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setMappingLocations(List mappingLocations) { + public DatabaseConfig setMappingLocations(List mappingLocations) { this.mappingLocations = mappingLocations; + return this; } @Override @@ -2251,8 +2414,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setIdGeneratorAutomatic(boolean idGeneratorAutomatic) { + public DatabaseConfig setIdGeneratorAutomatic(boolean idGeneratorAutomatic) { this.idGeneratorAutomatic = idGeneratorAutomatic; + return this; } @Override @@ -2261,8 +2425,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setQueryPlanEnable(boolean queryPlanEnable) { + public DatabaseConfig setQueryPlanEnable(boolean queryPlanEnable) { this.queryPlanEnable = queryPlanEnable; + return this; } @Override @@ -2271,8 +2436,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setQueryPlanThresholdMicros(long queryPlanThresholdMicros) { + public DatabaseConfig setQueryPlanThresholdMicros(long queryPlanThresholdMicros) { this.queryPlanThresholdMicros = queryPlanThresholdMicros; + return this; } @Override @@ -2281,8 +2447,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setQueryPlanCapture(boolean queryPlanCapture) { + public DatabaseConfig setQueryPlanCapture(boolean queryPlanCapture) { this.queryPlanCapture = queryPlanCapture; + return this; } @Override @@ -2291,8 +2458,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setQueryPlanCapturePeriodSecs(long queryPlanCapturePeriodSecs) { + public DatabaseConfig setQueryPlanCapturePeriodSecs(long queryPlanCapturePeriodSecs) { this.queryPlanCapturePeriodSecs = queryPlanCapturePeriodSecs; + return this; } @Override @@ -2301,8 +2469,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setQueryPlanCaptureMaxTimeMillis(long queryPlanCaptureMaxTimeMillis) { + public DatabaseConfig setQueryPlanCaptureMaxTimeMillis(long queryPlanCaptureMaxTimeMillis) { this.queryPlanCaptureMaxTimeMillis = queryPlanCaptureMaxTimeMillis; + return this; } @Override @@ -2311,8 +2480,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setQueryPlanCaptureMaxCount(int queryPlanCaptureMaxCount) { + public DatabaseConfig setQueryPlanCaptureMaxCount(int queryPlanCaptureMaxCount) { this.queryPlanCaptureMaxCount = queryPlanCaptureMaxCount; + return this; } @Override @@ -2321,8 +2491,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setQueryPlanListener(QueryPlanListener queryPlanListener) { + public DatabaseConfig setQueryPlanListener(QueryPlanListener queryPlanListener) { this.queryPlanListener = queryPlanListener; + return this; } @Override @@ -2331,8 +2502,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setDumpMetricsOnShutdown(boolean dumpMetricsOnShutdown) { + public DatabaseConfig setDumpMetricsOnShutdown(boolean dumpMetricsOnShutdown) { this.dumpMetricsOnShutdown = dumpMetricsOnShutdown; + return this; } @Override @@ -2341,8 +2513,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setDumpMetricsOptions(String dumpMetricsOptions) { + public DatabaseConfig setDumpMetricsOptions(String dumpMetricsOptions) { this.dumpMetricsOptions = dumpMetricsOptions; + return this; } @Override @@ -2361,8 +2534,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setLoadModuleInfo(boolean loadModuleInfo) { + public DatabaseConfig setLoadModuleInfo(boolean loadModuleInfo) { this.loadModuleInfo = loadModuleInfo; + return this; } @Override @@ -2371,8 +2545,9 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { } @Override - public void setMetricNaming(Function metricNaming) { + public DatabaseConfig setMetricNaming(Function metricNaming) { this.metricNaming = metricNaming; + return this; } public enum UuidVersion { diff --git a/ebean-core/src/test/java/io/ebeaninternal/server/deploy/BeanDescriptor_registerTest.java b/ebean-core/src/test/java/io/ebeaninternal/server/deploy/BeanDescriptor_registerTest.java index 255d15985..d72ccddad 100644 --- a/ebean-core/src/test/java/io/ebeaninternal/server/deploy/BeanDescriptor_registerTest.java +++ b/ebean-core/src/test/java/io/ebeaninternal/server/deploy/BeanDescriptor_registerTest.java @@ -1,8 +1,6 @@ package io.ebeaninternal.server.deploy; -import io.ebean.DatabaseFactory; -import io.ebean.DatabaseBuilder; -import io.ebean.config.DatabaseConfig; +import io.ebean.Database; import io.ebean.event.AbstractBeanPersistListener; import io.ebean.event.BeanPersistAdapter; import io.ebean.event.BeanPersistListener; @@ -18,16 +16,16 @@ public class BeanDescriptor_registerTest { @Test public void testRegisterDeregister() { - DatabaseBuilder config = new DatabaseConfig(); + Database db = Database.builder() + .setName("h2other") + .loadFromProperties() + .setDdlExtra(false) + .setRegister(false) + .setDefaultServer(false) + .addClass(EBasic.class) + .build(); - config.setName("h2other"); - config.loadFromProperties(); - config.setDdlExtra(false); - config.setRegister(false); - config.setDefaultServer(false); - config.addClass(EBasic.class); - - SpiEbeanServer ebeanServer = (SpiEbeanServer)DatabaseFactory.create(config); + SpiEbeanServer ebeanServer = (SpiEbeanServer)db; try { BeanDescriptor desc = ebeanServer.descriptor(EBasic.class); persistListenerRegistrationTests(desc);