From 12029ed06eec07253d81f0eb1f1358f679d201a9 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Fri, 3 Nov 2023 21:17:55 +1300 Subject: [PATCH 1/6] Refactor extract interface DatabaseBuilder from DatabaseConfig First step in supporting the builder pattern for creating Database --- composites/ebean/pom.xml | 4 +- .../src/main/java/io/ebean/Database.java | 2 +- .../main/java/io/ebean/DatabaseBuilder.java | 2006 +++++++++++++++++ .../main/java/io/ebean/DatabaseFactory.java | 7 +- .../ebean/cache/ServerCacheNotifyPlugin.java | 4 +- .../io/ebean/cache/ServerCachePlugin.java | 4 +- .../java/io/ebean/config/AutoConfigure.java | 6 +- .../java/io/ebean/config/DatabaseConfig.java | 1670 +++----------- .../ebean/config/DatabaseConfigProvider.java | 4 +- .../io/ebean/event/ServerConfigStartup.java | 4 +- .../main/java/io/ebean/plugin/SpiServer.java | 4 +- .../java/io/ebean/service/SpiContainer.java | 4 +- .../io/ebean/config/DatabaseConfigTest.java | 11 +- ebean-bom/pom.xml | 4 +- .../io/ebean/core/type/ExtraTypeFactory.java | 4 +- .../ebean/core/type/ScalarTypeSetFactory.java | 4 +- .../io/ebeaninternal/api/GeoTypeProvider.java | 4 +- .../autotune/AutoTuneServiceProvider.java | 4 +- .../server/cache/CacheManagerOptions.java | 12 +- .../cache/DefaultServerCachePlugin.java | 4 +- .../server/core/ClassPathScanners.java | 4 +- .../server/core/DatabasePlatformFactory.java | 4 +- .../server/core/DefaultContainer.java | 23 +- .../server/core/DefaultServer.java | 6 +- .../server/core/InitDataSource.java | 8 +- .../server/core/InternalConfiguration.java | 14 +- .../core/bootup/BootupClassPathSearch.java | 6 +- .../server/core/bootup/BootupClasses.java | 6 +- .../server/deploy/BeanDescriptor.java | 4 +- .../server/deploy/BeanDescriptorManager.java | 9 +- .../server/deploy/BeanDescriptorMap.java | 4 +- .../deploy/BeanLifecycleAdapterFactory.java | 4 +- .../GeneratedPropertyFactory.java | 8 +- .../deploy/meta/DeployBeanDescriptor.java | 6 +- .../server/deploy/parse/DeployUtil.java | 11 +- .../deploy/parse/ReadAnnotationConfig.java | 4 +- .../server/deploy/parse/ReadAnnotations.java | 4 +- .../server/query/CQueryEngine.java | 4 +- .../TransactionManagerOptions.java | 6 +- .../server/type/DefaultTypeFactory.java | 6 +- .../server/type/DefaultTypeManager.java | 20 +- .../server/core/InitDataSourceTest.java | 35 +- .../deploy/BeanDescriptor_registerTest.java | 3 +- .../deploy/parse/AnnotationClassTest.java | 7 +- .../server/type/DefaultTypeManagerTest.java | 3 +- .../server/type/TestTypeManager.java | 5 +- .../io/ebean/dbmigration/DbMigration.java | 4 +- .../dbmigration/DdlGenerator.java | 6 +- .../dbmigration/DefaultDbMigration.java | 26 +- .../io/ebeaninternal/dbmigration/Detect.java | 4 +- .../ddlgeneration/BaseDdlHandler.java | 6 +- .../ddlgeneration/platform/BaseTableDdl.java | 4 +- .../ddlgeneration/platform/ClickHouseDdl.java | 4 +- .../platform/ClickHouseDdlHandler.java | 4 +- .../platform/ClickHouseTableDdl.java | 4 +- .../ddlgeneration/platform/Db2HistoryDdl.java | 6 +- .../platform/DbTableBasedHistoryDdl.java | 6 +- .../platform/DbTriggerBasedHistoryDdl.java | 4 +- .../platform/HanaHistoryDdl.java | 4 +- .../platform/MariaDbHistoryDdl.java | 4 +- .../platform/NoHistorySupportDdl.java | 4 +- .../ddlgeneration/platform/PlatformDdl.java | 6 +- .../platform/PlatformHistoryDdl.java | 6 +- .../platform/SqlServerHistoryDdl.java | 4 +- .../dbmigration/model/PlatformDdlWriter.java | 12 +- .../ddlgeneration/BaseDdlHandlerTest.java | 3 +- .../platform/BaseTableDdlTest.java | 3 +- .../platform/PlatformDdl_AlterColumnTest.java | 4 +- .../platform/PlatformDdl_CreateIndexTest.java | 4 +- .../PlatformDdl_dropUniqueConstraintTest.java | 3 +- .../build/ModelBuildBeanVisitorTest.java | 3 +- .../build/ModelBuild_compoundKeyTest.java | 3 +- .../ModelBuild_compound_IdClassTest.java | 3 +- .../ModelBuild_explicitSequencesTest.java | 3 +- .../postgis/PostgisExtraTypeFactory.java | 4 +- .../postgis/PostgisGeoTypeBindProvider.java | 4 +- .../io/ebean/redis/RedisCacheFactory.java | 6 +- .../java/io/ebean/redis/RedisCachePlugin.java | 4 +- .../java/org/integration/ClusterTest.java | 3 +- .../org/example/EbeanServerFactoryBean.java | 8 +- ebean-test/pom.xml | 4 +- .../test/config/AutoConfigureForTesting.java | 14 +- .../io/ebean/test/config/platform/Config.java | 6 +- .../config/platform/PlatformAutoConfig.java | 6 +- .../config/provider/ProviderAutoConfig.java | 10 +- .../test/config/platform/ConfigTest.java | 25 +- .../EbeanServerFactory_MultiTenancy_Test.java | 7 +- ...nServerFactory_ServerConfigStart_Test.java | 11 +- .../xtest/config/DbMigrationConfigTest.java | 3 +- .../config/PlatformNoGeneratedKeysTest.java | 3 +- .../config/ServerConfigSqlServerTest.java | 7 +- .../DbMigrationDropHistoryTest.java | 3 +- .../dbmigration/DbMigrationGenerateTest.java | 3 +- .../xtest/dbmigration/DbMigrationTest.java | 5 +- .../xtest/event/BeanFindControllerTest.java | 5 +- .../event/BeanPersistControllerTest.java | 3 +- .../ebean/xtest/event/BeanPostLoadTest.java | 3 +- .../xtest/internal/api/TDSpiEbeanServer.java | 4 +- .../ebean/xtest/internal/api/TDSpiServer.java | 4 +- .../server/text/json/DJsonScalarTest.java | 3 +- .../DefaultTransactionThreadLocalTest.java | 3 +- .../partition/MultiTenantPartitionTest.java | 3 +- .../java/org/tests/basic/MainDbBoolean.java | 5 +- .../tests/basic/TestPersistenceContext.java | 5 +- .../basic/TestPersistenceContextMany.java | 5 +- .../org/tests/cache/TestBeanCacheAsync.java | 8 +- .../org/tests/changelog/TestChangeLog.java | 3 +- .../org/tests/json/TestJsonSourceDefault.java | 3 +- .../model/basic/MyEBasicConfigStartup.java | 4 +- .../TestPersistenceContextServerConfig.java | 3 +- .../org/tests/readaudit/TestReadAudit.java | 3 +- .../org/tests/timezone/LocalTimeTest.java | 3 +- .../org/tests/unitinternal/HelloMain.java | 3 +- .../sqlserver/SqlServerPlatformTest.java | 5 +- tests/test-java16/pom.xml | 2 +- 115 files changed, 2659 insertions(+), 1684 deletions(-) create mode 100644 ebean-api/src/main/java/io/ebean/DatabaseBuilder.java diff --git a/composites/ebean/pom.xml b/composites/ebean/pom.xml index a7dbeeb44..6cee65e1e 100644 --- a/composites/ebean/pom.xml +++ b/composites/ebean/pom.xml @@ -29,13 +29,13 @@ io.ebean ebean-joda-time - 13.18.0 + 13.24.0-RC1 io.ebean ebean-jackson-jsonnode - 13.18.0 + 13.24.0-RC1 diff --git a/ebean-api/src/main/java/io/ebean/Database.java b/ebean-api/src/main/java/io/ebean/Database.java index 9d329cd31..6c3b5e7fe 100644 --- a/ebean-api/src/main/java/io/ebean/Database.java +++ b/ebean-api/src/main/java/io/ebean/Database.java @@ -42,7 +42,7 @@ import java.util.concurrent.Callable; *
Constructing a Database
*

* Databases are constructed by the DatabaseFactory. They can be created - * programmatically via {@link DatabaseFactory#create(DatabaseConfig)} or they + * programmatically via {@link DatabaseFactory#create(DatabaseBuilder)} or they * can be automatically constructed on demand using configuration information in * the application.properties file. * diff --git a/ebean-api/src/main/java/io/ebean/DatabaseBuilder.java b/ebean-api/src/main/java/io/ebean/DatabaseBuilder.java new file mode 100644 index 000000000..1ecced869 --- /dev/null +++ b/ebean-api/src/main/java/io/ebean/DatabaseBuilder.java @@ -0,0 +1,2006 @@ +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.*; +import io.ebean.config.dbplatform.DatabasePlatform; +import io.ebean.config.dbplatform.DbEncrypt; +import io.ebean.config.dbplatform.DbType; +import io.ebean.config.dbplatform.IdType; +import io.ebean.datasource.DataSourceBuilder; +import io.ebean.event.*; +import io.ebean.event.changelog.ChangeLogListener; +import io.ebean.event.changelog.ChangeLogPrepare; +import io.ebean.event.changelog.ChangeLogRegister; +import io.ebean.event.readaudit.ReadAuditLogger; +import io.ebean.event.readaudit.ReadAuditPrepare; +import jakarta.persistence.EnumType; + +import javax.sql.DataSource; +import java.time.Clock; +import java.util.*; +import java.util.function.Function; + +public interface DatabaseBuilder { + /** + * Get the clock used for setting the timestamps (e.g. @UpdatedTimestamp) on objects. + */ + Clock getClock(); + + /** + * Set the clock used for setting the timestamps (e.g. @UpdatedTimestamp) on objects. + */ + void setClock(Clock clock); + + /** + * Return the slow query time in millis. + */ + long getSlowQueryMillis(); + + /** + * Set the slow query time in millis. + */ + void setSlowQueryMillis(long slowQueryMillis); + + /** + * Return the slow query event listener. + */ + SlowQueryListener getSlowQueryListener(); + + /** + * Set the slow query event listener. + */ + void 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); + + /** + * 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. + * You can also override some SPI objects that should be used for that Database. Currently, the following + * objects are possible. + *

+ */ + void putServiceObject(Class iface, T configObject); + + /** + * Return the service object given the key. + */ + Object getServiceObject(String key); + + /** + * Put a service object into configuration such that it can be used by ebean or a plugin. + * + *
{@code
+   *
+   *   JedisPool jedisPool = ..
+   *
+   *   config.putServiceObject(jedisPool);
+   *
+   * }
+ */ + void putServiceObject(Object configObject); + + default String serviceObjectKey(Object configObject) { + return serviceObjectKey(configObject.getClass()); + } + + default String serviceObjectKey(Class cls) { + String simpleName = cls.getSimpleName(); + return Character.toLowerCase(simpleName.charAt(0)) + simpleName.substring(1); + } + + /** + * Used by ebean or plugins to obtain service objects. + * + *
{@code
+   *
+   *   JedisPool jedisPool = config.getServiceObject(JedisPool.class);
+   *
+   * }
+ * + * @param cls The type of the service object to obtain + * @return The service object given the class type + */ + @SuppressWarnings("unchecked") +

P getServiceObject(Class

cls); + + /** + * Return the Jackson JsonFactory to use. + *

+ * If not set a default implementation will be used. + */ + JsonFactory getJsonFactory(); + + /** + * Set the Jackson JsonFactory to use. + *

+ * If not set a default implementation will be used. + */ + void setJsonFactory(JsonFactory jsonFactory); + + /** + * Return the JSON format used for DateTime types. + */ + JsonConfig.DateTime getJsonDateTime(); + + /** + * Set the JSON format to use for DateTime types. + */ + void setJsonDateTime(JsonConfig.DateTime jsonDateTime); + + /** + * Return the JSON format used for Date types. + */ + JsonConfig.Date getJsonDate(); + + /** + * Set the JSON format to use for Date types. + */ + void setJsonDate(JsonConfig.Date jsonDate); + + /** + * Return the JSON include mode used when writing JSON. + */ + JsonConfig.Include getJsonInclude(); + + /** + * 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); + + /** + * Return the default MutableDetection to use with {@code @DbJson} using Jackson. + * + * @see DbJson#mutationDetection() + */ + MutationDetection getJsonMutationDetection(); + + /** + * Set the default MutableDetection to use with {@code @DbJson} using Jackson. + * + * @see DbJson#mutationDetection() + */ + void setJsonMutationDetection(MutationDetection jsonMutationDetection); + + /** + * Return the name of the Database. + */ + String getName(); + + /** + * Set the name of the Database. + */ + void setName(String name); + + /** + * Return the container / clustering configuration. + *

+ * The container holds all the Database instances and provides clustering communication + * services to all the Database instances. + */ + ContainerConfig getContainerConfig(); + + /** + * Set the container / clustering configuration. + *

+ * The container holds all the Database instances and provides clustering communication + * services to all the Database instances. + */ + void setContainerConfig(ContainerConfig containerConfig); + + /** + * Return true if this server should be registered with the Ebean singleton + * when it is created. + *

+ * By default this is set to true. + */ + boolean isRegister(); + + /** + * 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); + + /** + * Return true if this server should be registered as the "default" server + * with the Ebean singleton. + *

+ * This is only used when {@link #setRegister(boolean)} is also true. + */ + boolean isDefaultServer(); + + /** + * 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); + + /** + * Return the CurrentUserProvider. This is used to populate @WhoCreated, @WhoModified and + * support other audit features (who executed a query etc). + */ + CurrentUserProvider getCurrentUserProvider(); + + /** + * Set the CurrentUserProvider. This is used to populate @WhoCreated, @WhoModified and + * support other audit features (who executed a query etc). + */ + void setCurrentUserProvider(CurrentUserProvider currentUserProvider); + + /** + * Return the tenancy mode used. + */ + TenantMode getTenantMode(); + + /** + * Set the tenancy mode to use. + */ + void setTenantMode(TenantMode tenantMode); + + /** + * Return the column name used for TenantMode.PARTITION. + */ + String getTenantPartitionColumn(); + + /** + * Set the column name used for TenantMode.PARTITION. + */ + void setTenantPartitionColumn(String tenantPartitionColumn); + + /** + * Return the current tenant provider. + */ + CurrentTenantProvider getCurrentTenantProvider(); + + /** + * Set the current tenant provider. + */ + void setCurrentTenantProvider(CurrentTenantProvider currentTenantProvider); + + /** + * Return the tenancy datasource provider. + */ + TenantDataSourceProvider getTenantDataSourceProvider(); + + /** + * Set the tenancy datasource provider. + */ + void setTenantDataSourceProvider(TenantDataSourceProvider tenantDataSourceProvider); + + /** + * Return the tenancy schema provider. + */ + TenantSchemaProvider getTenantSchemaProvider(); + + /** + * Set the tenancy schema provider. + */ + void setTenantSchemaProvider(TenantSchemaProvider tenantSchemaProvider); + + /** + * Return the tenancy catalog provider. + */ + TenantCatalogProvider getTenantCatalogProvider(); + + /** + * Set the tenancy catalog provider. + */ + void setTenantCatalogProvider(TenantCatalogProvider tenantCatalogProvider); + + /** + * Return true if dirty beans are automatically persisted. + */ + boolean isAutoPersistUpdates(); + + /** + * Set to true if dirty beans are automatically persisted. + */ + void setAutoPersistUpdates(boolean autoPersistUpdates); + + /** + * Return the PersistBatch mode to use by default 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. + */ + PersistBatch getPersistBatch(); + + /** + * 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); + + /** + * Return the JDBC batch mode to use per save(), delete(), insert() or update() request. + *

+ * This makes sense when a save() or delete() cascades and executes multiple child statements. The best case + * 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. + */ + PersistBatch getPersistBatchOnCascade(); + + /** + * 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); + + /** + * Return the batch size used for JDBC batching. This defaults to 20. + */ + int getPersistBatchSize(); + + /** + * 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); + + /** + * Gets the query batch size. This defaults to 100. + * + * @return the query batch size + */ + int getQueryBatchSize(); + + /** + * Sets the query batch size. This defaults to 100. + * + * @param queryBatchSize the new query batch size + */ + void setQueryBatchSize(int queryBatchSize); + + EnumType getDefaultEnumType(); + + void setDefaultEnumType(EnumType defaultEnumType); + + /** + * Return true if lazy loading is disabled on queries by default. + */ + boolean isDisableLazyLoading(); + + /** + * 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); + + /** + * Return the default batch size for lazy loading of beans and collections. + */ + int getLazyLoadBatchSize(); + + /** + * 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); + + /** + * Set the number of sequences to fetch/preallocate when using DB sequences. + *

+ * This is a performance optimisation to reduce the number times Ebean + * requests a sequence to be used as an Id for a bean (aka reduce network + * chatter). + */ + void setDatabaseSequenceBatchSize(int databaseSequenceBatchSize); + + /** + * Return the default JDBC fetchSize hint for findList queries. + */ + int getJdbcFetchSizeFindList(); + + /** + * Set the default JDBC fetchSize hint for findList queries. + */ + void setJdbcFetchSizeFindList(int jdbcFetchSizeFindList); + + /** + * Return the default JDBC fetchSize hint for findEach/findEachWhile queries. + */ + int getJdbcFetchSizeFindEach(); + + /** + * Set the default JDBC fetchSize hint for findEach/findEachWhile queries. + */ + void setJdbcFetchSizeFindEach(int jdbcFetchSizeFindEach); + + /** + * Return the ChangeLogPrepare. + *

+ * This is used to set user context information to the ChangeSet in the + * foreground thread prior to the logging occurring in a background thread. + */ + ChangeLogPrepare getChangeLogPrepare(); + + /** + * Set the ChangeLogPrepare. + *

+ * 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); + + /** + * Return the ChangeLogListener which actually performs the logging of change sets + * in the background. + */ + ChangeLogListener getChangeLogListener(); + + /** + * Set the ChangeLogListener which actually performs the logging of change sets + * in the background. + */ + void setChangeLogListener(ChangeLogListener changeLogListener); + + /** + * Return 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. + */ + ChangeLogRegister getChangeLogRegister(); + + /** + * 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); + + /** + * Return true if inserts should be included in the change log by default. + */ + boolean isChangeLogIncludeInserts(); + + /** + * Set if inserts should be included in the change log by default. + */ + void setChangeLogIncludeInserts(boolean changeLogIncludeInserts); + + /** + * Return true (default) if the changelog should be written async. + */ + boolean isChangeLogAsync(); + + /** + * Sets if the changelog should be written async (default = true). + */ + void setChangeLogAsync(boolean changeLogAsync); + + /** + * Return the ReadAuditLogger to use. + */ + ReadAuditLogger getReadAuditLogger(); + + /** + * 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); + + /** + * Return the ReadAuditPrepare to use. + */ + ReadAuditPrepare getReadAuditPrepare(); + + /** + * Set the ReadAuditPrepare to use. + *

+ * It is expected that an implementation is used that read user context information + * (user id, user ip address etc) and sets it on the ReadEvent bean before it is sent + * to the ReadAuditLogger. + */ + void setReadAuditPrepare(ReadAuditPrepare readAuditPrepare); + + /** + * Return the configuration for profiling. + */ + ProfilingConfig getProfilingConfig(); + + /** + * Set the configuration for profiling. + */ + void setProfilingConfig(ProfilingConfig profilingConfig); + + /** + * Return the DB schema to use. + */ + String getDbSchema(); + + /** + * 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); + + /** + * Return the Geometry SRID. + */ + int getGeometrySRID(); + + /** + * Set the Geometry SRID. + */ + void setGeometrySRID(int geometrySRID); + + /** + * Return the time zone to use when reading/writing Timestamps via JDBC. + *

+ * When set a Calendar object is used in JDBC calls when reading/writing Timestamp objects. + */ + String getDataTimeZone(); + + /** + * Set the time zone to use when reading/writing Timestamps via JDBC. + */ + void setDataTimeZone(String dataTimeZone); + + /** + * Return 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. + */ + String getAsOfViewSuffix(); + + /** + * 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); + + /** + * Return the database column used to support history and 'As of' queries. This column is a timestamp range + * or equivalent. + */ + String getAsOfSysPeriod(); + + /** + * Set the database column used to support history and 'As of' queries. This column is a timestamp range + * or equivalent. + */ + void setAsOfSysPeriod(String asOfSysPeriod); + + /** + * Return the history table suffix (defaults to _history). + */ + String getHistoryTableSuffix(); + + /** + * Set the history table suffix. + */ + void setHistoryTableSuffix(String historyTableSuffix); + + /** + * Return true if we are running in a JTA Transaction manager. + */ + boolean isUseJtaTransactionManager(); + + /** + * Set to true if we are running in a JTA Transaction manager. + */ + void setUseJtaTransactionManager(boolean useJtaTransactionManager); + + /** + * Return the external transaction manager. + */ + ExternalTransactionManager getExternalTransactionManager(); + + /** + * Set the external transaction manager. + */ + void setExternalTransactionManager(ExternalTransactionManager externalTransactionManager); + + /** + * Return the ServerCachePlugin. + */ + ServerCachePlugin getServerCachePlugin(); + + /** + * Set the ServerCachePlugin to use. + */ + void setServerCachePlugin(ServerCachePlugin serverCachePlugin); + + /** + * Return true if LOB's should default to fetch eager. + * By default this is set to false and LOB's must be explicitly fetched. + */ + boolean isEagerFetchLobs(); + + /** + * 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); + + /** + * Return the max call stack to use for origin location. + */ + int getMaxCallStack(); + + /** + * Set the max call stack to use for origin location. + */ + void setMaxCallStack(int maxCallStack); + + /** + * Return true if transactions should rollback on checked exceptions. + */ + boolean isTransactionRollbackOnChecked(); + + /** + * Set to true if transactions should by default rollback on checked exceptions. + */ + void setTransactionRollbackOnChecked(boolean transactionRollbackOnChecked); + + /** + * Return the Background executor schedule pool size. Defaults to 1. + */ + int getBackgroundExecutorSchedulePoolSize(); + + /** + * Set the Background executor schedule pool size. + */ + void setBackgroundExecutorSchedulePoolSize(int backgroundExecutorSchedulePoolSize); + + /** + * Return the Background executor shutdown seconds. This is the time allowed for the pool to shutdown nicely + * before it is forced shutdown. + */ + int getBackgroundExecutorShutdownSecs(); + + /** + * 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); + + /** + * Return the background executor wrapper. + */ + BackgroundExecutorWrapper getBackgroundExecutorWrapper(); + + /** + * 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); + + /** + * Return the L2 cache default max size. + */ + int getCacheMaxSize(); + + /** + * Set the L2 cache default max size. + */ + void setCacheMaxSize(int cacheMaxSize); + + /** + * Return the L2 cache default max idle time in seconds. + */ + int getCacheMaxIdleTime(); + + /** + * Set the L2 cache default max idle time in seconds. + */ + void setCacheMaxIdleTime(int cacheMaxIdleTime); + + /** + * Return the L2 cache default max time to live in seconds. + */ + int getCacheMaxTimeToLive(); + + /** + * Set the L2 cache default max time to live in seconds. + */ + void setCacheMaxTimeToLive(int cacheMaxTimeToLive); + + /** + * Return the L2 query cache default max size. + */ + int getQueryCacheMaxSize(); + + /** + * Set the L2 query cache default max size. + */ + void setQueryCacheMaxSize(int queryCacheMaxSize); + + /** + * Return the L2 query cache default max idle time in seconds. + */ + int getQueryCacheMaxIdleTime(); + + /** + * Set the L2 query cache default max idle time in seconds. + */ + void setQueryCacheMaxIdleTime(int queryCacheMaxIdleTime); + + /** + * Return the L2 query cache default max time to live in seconds. + */ + int getQueryCacheMaxTimeToLive(); + + /** + * Set the L2 query cache default max time to live in seconds. + */ + void setQueryCacheMaxTimeToLive(int queryCacheMaxTimeToLive); + + /** + * Return the NamingConvention. + *

+ * If none has been set the default UnderscoreNamingConvention is used. + */ + NamingConvention getNamingConvention(); + + /** + * Set the NamingConvention. + *

+ * If none is set the default UnderscoreNamingConvention is used. + */ + void setNamingConvention(NamingConvention namingConvention); + + /** + * Return true if all DB column and table names should use quoted identifiers. + */ + boolean isAllQuotedIdentifiers(); + + /** + * Set to true if all DB column and table names should use quoted identifiers. + *

+ * For Postgres pgjdbc version 42.3.0 should be used with datasource property + * quoteReturningIdentifiers set to false (refer #2303). + */ + void setAllQuotedIdentifiers(boolean allQuotedIdentifiers); + + /** + * Return true if this Database is a Document store only instance (has no JDBC DB). + */ + boolean isDocStoreOnly(); + + /** + * Set to true if this Database is Document store only instance (has no JDBC DB). + */ + void setDocStoreOnly(boolean docStoreOnly); + + /** + * Return the configuration for the ElasticSearch integration. + */ + DocStoreConfig getDocStoreConfig(); + + /** + * Set the configuration for the ElasticSearch integration. + */ + void setDocStoreConfig(DocStoreConfig docStoreConfig); + + /** + * Return the constraint naming convention used in DDL generation. + */ + DbConstraintNaming getConstraintNaming(); + + /** + * Set the constraint naming convention used in DDL generation. + */ + void setConstraintNaming(DbConstraintNaming constraintNaming); + + /** + * Return the configuration for AutoTune. + */ + AutoTuneConfig getAutoTuneConfig(); + + /** + * Set the configuration for AutoTune. + */ + void setAutoTuneConfig(AutoTuneConfig autoTuneConfig); + + /** + * Return true if the startup DataSource check should be skipped. + */ + boolean skipDataSourceCheck(); + + /** + * Set to true to skip the startup DataSource check. + */ + void setSkipDataSourceCheck(boolean skipDataSourceCheck); + + /** + * Return the DataSource. + */ + DataSource getDataSource(); + + /** + * Set a DataSource. + */ + void setDataSource(DataSource dataSource); + + /** + * Return the read only DataSource. + */ + DataSource getReadOnlyDataSource(); + + /** + * Set the read only DataSource. + *

+ * Note that the DataSource is expected to use AutoCommit true mode avoiding the need + * for explicit commit (or rollback). + *

+ * 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); + + /** + * Return the configuration to build a DataSource using Ebean's own DataSource + * implementation. + */ + DataSourceBuilder getDataSourceConfig(); + + /** + * Set the configuration required to build a DataSource using Ebean's own + * DataSource implementation. + */ + void setDataSourceConfig(DataSourceBuilder dataSourceConfig); + + /** + * Return true if Ebean should create a DataSource for use with implicit read only transactions. + */ + boolean isAutoReadOnlyDataSource(); + + /** + * Set to true if Ebean should create a DataSource for use with implicit read only transactions. + */ + void setAutoReadOnlyDataSource(boolean autoReadOnlyDataSource); + + /** + * Return the configuration for the read only DataSource. + *

+ * This is only used if autoReadOnlyDataSource is true. + *

+ * The driver, url, username and password default to the configuration for the main DataSource if they are not + * set on this configuration. This means there is actually no need to set any configuration here and we only + * set configuration for url, username and password etc if it is different from the main DataSource. + */ + DataSourceBuilder getReadOnlyDataSourceConfig(); + + /** + * Set the configuration for the read only DataSource. + */ + void setReadOnlyDataSourceConfig(DataSourceBuilder readOnlyDataSourceConfig); + + /** + * Return a value used to represent TRUE in the database. + *

+ * This is used for databases that do not support boolean natively. + *

+ * The value returned is either a Integer or a String (e.g. "1", or "T"). + */ + String getDatabaseBooleanTrue(); + + /** + * Set the value to represent TRUE in the database. + *

+ * This is used for databases that do not support boolean natively. + *

+ * The value set is either a Integer or a String (e.g. "1", or "T"). + */ + void setDatabaseBooleanTrue(String databaseTrue); + + /** + * Return a value used to represent FALSE in the database. + *

+ * This is used for databases that do not support boolean natively. + *

+ * The value returned is either a Integer or a String (e.g. "0", or "F"). + */ + String getDatabaseBooleanFalse(); + + /** + * Set the value to represent FALSE in the database. + *

+ * This is used for databases that do not support boolean natively. + *

+ * The value set is either a Integer or a String (e.g. "0", or "F"). + */ + void setDatabaseBooleanFalse(String databaseFalse); + + /** + * Return the number of DB sequence values that should be preallocated. + */ + int getDatabaseSequenceBatchSize(); + + /** + * Set the number of DB sequence values that should be preallocated and cached + * by Ebean. + *

+ * This is only used for DB's that use sequences and is a performance + * optimisation. This reduces the number of times Ebean needs to get a + * sequence value from the Database reducing network chatter. + *

+ * By default this value is 10 so when we need another Id (and don't have one + * in our cache) Ebean will fetch 10 id's from the database. Note that when + * 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); + + /** + * Return the database platform name (can be null). + *

+ * If null then the platform is determined automatically via the JDBC driver + * information. + */ + String getDatabasePlatformName(); + + /** + * Explicitly set the database platform name + *

+ * If none is set then the platform is determined automatically via the JDBC + * driver information. + *

+ * This can be used when the Database Platform can not be automatically + * detected from the JDBC driver (possibly 3rd party JDBC driver). It is also + * useful when you want to do offline DDL generation for a database platform + * that you don't have access to. + *

+ * Values are oracle, h2, postgres, mysql, sqlserver16, sqlserver17. + */ + void setDatabasePlatformName(String databasePlatformName); + + /** + * Return the database platform to use for this database. + */ + DatabasePlatform getDatabasePlatform(); + + /** + * Explicitly set the database platform to use. + *

+ * If none is set then the platform is determined via the databasePlatformName + * or automatically via the JDBC driver information. + */ + void setDatabasePlatform(DatabasePlatform databasePlatform); + + /** + * Return the preferred DB platform IdType. + */ + IdType getIdType(); + + /** + * Set the preferred DB platform IdType. + */ + void setIdType(IdType idType); + + /** + * Return the EncryptKeyManager. + */ + EncryptKeyManager getEncryptKeyManager(); + + /** + * Set the EncryptKeyManager. + *

+ * This is required when you want to use encrypted properties. + *

+ * You can also set this in ebean.proprerties: + *

+ *

{@code
+   * # set via ebean.properties
+   * ebean.encryptKeyManager=org.avaje.tests.basic.encrypt.BasicEncyptKeyManager
+   * }
+ */ + void setEncryptKeyManager(EncryptKeyManager encryptKeyManager); + + /** + * Return the EncryptDeployManager. + *

+ * This is optionally used to programmatically define which columns are + * encrypted instead of using the {@link Encrypted} Annotation. + */ + EncryptDeployManager getEncryptDeployManager(); + + /** + * Set the EncryptDeployManager. + *

+ * This is optionally used to programmatically define which columns are + * encrypted instead of using the {@link Encrypted} Annotation. + */ + void setEncryptDeployManager(EncryptDeployManager encryptDeployManager); + + /** + * Return the Encryptor used to encrypt data on the java client side (as + * opposed to DB encryption functions). + */ + Encryptor getEncryptor(); + + /** + * Set the Encryptor used to encrypt data on the java client side (as opposed + * to DB encryption functions). + *

+ * Ebean has a default implementation that it will use if you do not set your + * own Encryptor implementation. + */ + void setEncryptor(Encryptor encryptor); + + /** + * Return true if the Database instance should be created in offline mode. + */ + boolean isDbOffline(); + + /** + * Set to true if the Database instance should be created in offline mode. + *

+ * Typically used to create an Database instance for DDL Migration generation + * without requiring a real DataSource / Database to connect to. + */ + void setDbOffline(boolean dbOffline); + + /** + * Return the DbEncrypt used to encrypt and decrypt properties. + *

+ * Note that if this is not set then the DbPlatform may already have a + * DbEncrypt set and that will be used. + */ + DbEncrypt getDbEncrypt(); + + /** + * Set the DbEncrypt used to encrypt and decrypt properties. + *

+ * 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); + + /** + * Return the configuration for DB types (such as UUID and custom mappings). + */ + PlatformConfig getPlatformConfig(); + + /** + * Set the configuration for DB platform (such as UUID and custom mappings). + */ + void setPlatformConfig(PlatformConfig platformConfig); + + /** + * Set the DB type used to store UUID. + */ + void setDbUuid(PlatformConfig.DbUuid dbUuid); + + /** + * Returns the UUID version mode. + */ + DatabaseConfig.UuidVersion getUuidVersion(); + + /** + * Sets the UUID version mode. + */ + void setUuidVersion(DatabaseConfig.UuidVersion uuidVersion); + + /** + * Return the UUID state file. + */ + String getUuidStateFile(); + + /** + * Set the UUID state file. + */ + void setUuidStateFile(String uuidStateFile); + + /** + * Returns the V1-UUID-NodeId + */ + String getUuidNodeId(); + + /** + * Sets the V1-UUID-NodeId. + */ + void setUuidNodeId(String uuidNodeId); + + /** + * Return true if LocalTime should be persisted with nanos precision. + */ + boolean isLocalTimeWithNanos(); + + /** + * 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); + + /** + * Return true if Duration should be persisted with nanos precision (SQL DECIMAL). + *

+ * Otherwise it is persisted with second precision (SQL INTEGER). + */ + boolean isDurationWithNanos(); + + /** + * 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); + + /** + * Set to true to run DB migrations on server start. + *

+ * 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); + + /** + * Return true if the DB migration should run on server start. + */ + boolean isRunMigration(); + + /** + * Set to true to generate the "create all" DDL on startup. + *

+ * 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); + + /** + * Set to true to run the generated "create all DDL" on startup. + *

+ * 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); + + /** + * 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); + + /** + * Return true if the "drop all ddl" should be skipped. + *

+ * 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. + */ + boolean isDdlCreateOnly(); + + /** + * Set to true if the "drop all ddl" should be skipped. + *

+ * 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); + + /** + * Return SQL script to execute after the "create all" DDL has been run. + *

+ * 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. + */ + String getDdlSeedSql(); + + /** + * Set a SQL script to execute after the "create all" DDL has been run. + *

+ * 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); + + /** + * Return a SQL script to execute before the "create all" DDL has been run. + */ + String getDdlInitSql(); + + /** + * Set a SQL script to execute before the "create all" DDL has been run. + */ + void setDdlInitSql(String ddlInitSql); + + /** + * Return true if the DDL should be generated. + */ + boolean isDdlGenerate(); + + /** + * Return true if the DDL should be run. + */ + boolean isDdlRun(); + + /** + * Return true, if extra-ddl.xml should be executed. + */ + boolean isDdlExtra(); + + /** + * Set the header to use with DDL generation. + */ + void setDdlHeader(String ddlHeader); + + /** + * Return the header to use with DDL generation. + */ + String getDdlHeader(); + + /** + * Return true if strict mode is used which includes a check that non-null columns have a default value. + */ + boolean isDdlStrictMode(); + + /** + * Set to false to turn off strict mode allowing non-null columns to not have a default value. + */ + void setDdlStrictMode(boolean ddlStrictMode); + + /** + * Return a comma and equals delimited placeholders that are substituted in DDL scripts. + */ + String getDdlPlaceholders(); + + /** + * Set a comma and equals delimited placeholders that are substituted in DDL scripts. + */ + void setDdlPlaceholders(String ddlPlaceholders); + + /** + * Return a map of placeholder values that are substituted in DDL scripts. + */ + Map getDdlPlaceholderMap(); + + /** + * Set a map of placeholder values that are substituted in DDL scripts. + */ + void setDdlPlaceholderMap(Map ddlPlaceholderMap); + + /** + * Return true if the class path search should be disabled. + */ + boolean isDisableClasspathSearch(); + + /** + * 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); + + /** + * Return the mode to use for Joda LocalTime support 'normal' or 'utc'. + */ + String getJodaLocalTimeMode(); + + /** + * Set the mode to use for Joda LocalTime support 'normal' or 'utc'. + */ + void setJodaLocalTimeMode(String jodaLocalTimeMode); + + /** + * Programmatically add classes (typically entities) that this server should use. + *

+ * The class can be an Entity, Embedded type, ScalarType, BeanPersistListener, + * BeanFinder or BeanPersistController. + *

+ * If no classes are specified then the classes are found automatically via + * searching the class path. + * + * @param cls the entity type (or other type) that should be registered by this database. + */ + void addClass(Class cls); + + /** + * Register all the classes (typically entity classes). + */ + void 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); + + /** + * Return packages to search for entities via class path search. + *

+ * This is only used if classes have not been explicitly specified. + */ + List getPackages(); + + /** + * 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); + + /** + * Set the list of classes (entities, listeners, scalarTypes etc) that should + * be used for this database. + *

+ * If no classes are specified then the classes are found automatically via + * searching the class path. + *

+ * Alternatively the classes can contain added via {@link #addClass(Class)}. + */ + void setClasses(Collection> classes); + + /** + * Return the classes registered for this database. Typically, this includes + * entities and perhaps listeners. + */ + Set> classes(); + + /** + * @deprecated - migrate to {@link #classes()}. + *

+ * Sorry if returning Set rather than List breaks code but it feels safer to + * do that than a subtle change to return a shallow copy which you will not detect. + */ + @Deprecated(forRemoval = true) + Set> getClasses(); + + /** + * Return true if L2 bean cache should be skipped once writes have occurred on a transaction. + *

+ * This defaults to true and means that for "find by id" and "find by natural key" + * queries that normally hit L2 bean cache automatically will not do so after a write/persist + * on the transaction. + *

+ *

{@code
+   *
+   *   // assume Customer has L2 bean caching enabled ...
+   *
+   *   try (Transaction transaction = DB.beginTransaction()) {
+   *
+   *     // this uses L2 bean cache as the transaction
+   *     // ... is considered "query only" at this point
+   *     Customer.find.byId(42);
+   *
+   *     // transaction no longer "query only" once
+   *     // ... a bean has been saved etc
+   *     DB.save(someBean);
+   *
+   *     // will NOT use L2 bean cache as the transaction
+   *     // ... is no longer considered "query only"
+   *     Customer.find.byId(55);
+   *
+   *
+   *
+   *     // explicit control - please use L2 bean cache
+   *
+   *     transaction.setSkipCache(false);
+   *     Customer.find.byId(77); // hit the l2 bean cache
+   *
+   *
+   *     // explicit control - please don't use L2 bean cache
+   *
+   *     transaction.setSkipCache(true);
+   *     Customer.find.byId(99); // skips l2 bean cache
+   *
+   *   }
+   *
+   * }
+ * + * @see Transaction#setSkipCache(boolean) + */ + boolean isSkipCacheAfterWrite(); + + /** + * Set to false when we still want to hit the cache after a write has occurred on a transaction. + */ + void setSkipCacheAfterWrite(boolean skipCacheAfterWrite); + + /** + * Returns true if updates in JDBC batch default to include all properties by default. + */ + boolean isUpdateAllPropertiesInBatch(); + + /** + * Set to false if by default updates in JDBC batch should not include all properties. + *

+ * This mode can be explicitly set per transaction. + * + * @see Transaction#setUpdateAllLoadedProperties(boolean) + */ + void setUpdateAllPropertiesInBatch(boolean updateAllPropertiesInBatch); + + /** + * Returns the resource directory. + */ + String getResourceDirectory(); + + /** + * Sets the resource directory. + */ + void setResourceDirectory(String resourceDirectory); + + /** + * Add a custom type mapping. + *

+ *

{@code
+   *
+   *   // set the default mapping for BigDecimal.class/decimal
+   *   config.addCustomMapping(DbType.DECIMAL, "decimal(18,6)");
+   *
+   *   // set the default mapping for String.class/varchar but only for Postgres
+   *   config.addCustomMapping(DbType.VARCHAR, "text", Platform.POSTGRES);
+   *
+   * }
+ * + * @param type The DB type this mapping should apply to + * @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); + + /** + * Add a custom type mapping that applies to all platforms. + *

+ *

{@code
+   *
+   *   // set the default mapping for BigDecimal/decimal
+   *   config.addCustomMapping(DbType.DECIMAL, "decimal(18,6)");
+   *
+   *   // set the default mapping for String/varchar
+   *   config.addCustomMapping(DbType.VARCHAR, "text");
+   *
+   * }
+ * + * @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); + + /** + * Register a BeanQueryAdapter instance. + *

+ * Note alternatively you can use {@link #setQueryAdapters(List)} to set all + * the BeanQueryAdapter instances. + */ + void add(BeanQueryAdapter beanQueryAdapter); + + /** + * Return the BeanQueryAdapter instances. + */ + List getQueryAdapters(); + + /** + * Register all the BeanQueryAdapter instances. + *

+ * Note alternatively you can use {@link #add(BeanQueryAdapter)} to add + * BeanQueryAdapter instances one at a time. + */ + void setQueryAdapters(List queryAdapters); + + /** + * Return the custom IdGenerator instances. + */ + List getIdGenerators(); + + /** + * Set the custom IdGenerator instances. + */ + void setIdGenerators(List idGenerators); + + /** + * Register a customer IdGenerator instance. + */ + void add(IdGenerator idGenerator); + + /** + * Register a BeanPersistController instance. + *

+ * Note alternatively you can use {@link #setPersistControllers(List)} to set + * all the BeanPersistController instances. + */ + void add(BeanPersistController beanPersistController); + + /** + * Register a BeanPostLoad instance. + *

+ * Note alternatively you can use {@link #setPostLoaders(List)} to set + * all the BeanPostLoad instances. + */ + void add(BeanPostLoad postLoad); + + /** + * Register a BeanPostConstructListener instance. + *

+ * Note alternatively you can use {@link #setPostConstructListeners(List)} to set + * all the BeanPostConstructListener instances. + */ + void add(BeanPostConstructListener listener); + + /** + * Return the list of BeanFindController instances. + */ + List getFindControllers(); + + /** + * Set the list of BeanFindController instances. + */ + void setFindControllers(List findControllers); + + /** + * Return the list of BeanPostLoader instances. + */ + List getPostLoaders(); + + /** + * Set the list of BeanPostLoader instances. + */ + void setPostLoaders(List postLoaders); + + /** + * Return the list of BeanPostLoader instances. + */ + List getPostConstructListeners(); + + /** + * Set the list of BeanPostLoader instances. + */ + void setPostConstructListeners(List listeners); + + /** + * Return the BeanPersistController instances. + */ + List getPersistControllers(); + + /** + * Register all the BeanPersistController instances. + *

+ * Note alternatively you can use {@link #add(BeanPersistController)} to add + * BeanPersistController instances one at a time. + */ + void setPersistControllers(List persistControllers); + + /** + * Register a BeanPersistListener instance. + *

+ * Note alternatively you can use {@link #setPersistListeners(List)} to set + * all the BeanPersistListener instances. + */ + void add(BeanPersistListener beanPersistListener); + + /** + * Return the BeanPersistListener instances. + */ + List getPersistListeners(); + + /** + * Add a BulkTableEventListener + */ + void add(BulkTableEventListener bulkTableEventListener); + + /** + * Return the list of BulkTableEventListener instances. + */ + List getBulkTableEventListeners(); + + /** + * Add a ServerConfigStartup. + */ + void addServerConfigStartup(ServerConfigStartup configStartupListener); + + /** + * Return the list of ServerConfigStartup instances. + */ + List getServerConfigStartupListeners(); + + /** + * Register all the BeanPersistListener instances. + *

+ * Note alternatively you can use {@link #add(BeanPersistListener)} to add + * BeanPersistListener instances one at a time. + */ + void setPersistListeners(List persistListeners); + + /** + * Return the default PersistenceContextScope to be used if one is not explicitly set on a query. + *

+ * The PersistenceContextScope can specified on each query via {@link io.ebean + * .Query#setPersistenceContextScope(io.ebean.PersistenceContextScope)}. If it + * is not set on the query this default scope is used. + * + * @see Query#setPersistenceContextScope(PersistenceContextScope) + */ + PersistenceContextScope getPersistenceContextScope(); + + /** + * Set the PersistenceContext scope to be used if one is not explicitly set on a query. + *

+ * This defaults to {@link PersistenceContextScope#TRANSACTION}. + *

+ * The PersistenceContextScope can specified on each query via {@link io.ebean + * .Query#setPersistenceContextScope(io.ebean.PersistenceContextScope)}. If it + * is not set on the query this scope is used. + * + * @see Query#setPersistenceContextScope(PersistenceContextScope) + */ + void setPersistenceContextScope(PersistenceContextScope persistenceContextScope); + + /** + * Return the ClassLoadConfig which is used to detect Joda, Java8 types etc and also + * create new instances of plugins given a className. + */ + ClassLoadConfig getClassLoadConfig(); + + /** + * 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); + + /** + * Load settings from application.properties, application.yaml and other sources. + *

+ * Uses avaje-config to load configuration properties. Goto https://avaje.io/config + * for detail on how and where properties are loaded from. + */ + void loadFromProperties(); + + /** + * Load the settings from the given properties + */ + void loadFromProperties(Properties properties); + + /** + * Return the properties that we used for configuration and were set via a call to loadFromProperties(). + */ + Properties getProperties(); + + /** + * Return the PersistBatch mode to use for 'batchOnCascade' taking into account if the database + * platform supports getGeneratedKeys in batch mode. + */ + PersistBatch appliedPersistBatchOnCascade(); + + /** + * Return the Jackson ObjectMapper. + *

+ * Note that this is not strongly typed as Jackson ObjectMapper is an optional dependency. + */ + Object getObjectMapper(); + + /** + * Set the Jackson ObjectMapper. + *

+ * Note that this is not strongly typed as Jackson ObjectMapper is an optional dependency. + */ + void setObjectMapper(Object objectMapper); + + /** + * Return true if eq("someProperty", null) should to generate "1=1" rather than "is null" sql expression. + */ + boolean isExpressionEqualsWithNullAsNoop(); + + /** + * Set to true if you want eq("someProperty", null) to generate "1=1" rather than "is null" sql expression. + *

+ * Setting this to true has the effect that eq(propertyName, value), ieq(propertyName, value) and + * 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); + + /** + * Return true if native ILIKE expression should be used if supported by the database platform (e.g. Postgres). + */ + boolean isExpressionNativeIlike(); + + /** + * Set to true to use native ILIKE expression if supported by the database platform (e.g. Postgres). + */ + void setExpressionNativeIlike(boolean expressionNativeIlike); + + /** + * Return the enabled L2 cache regions. + */ + String getEnabledL2Regions(); + + /** + * Set the enabled L2 cache regions (comma delimited). + */ + void setEnabledL2Regions(String enabledL2Regions); + + /** + * Return true if L2 cache is disabled. + */ + boolean isDisableL2Cache(); + + /** + * Set to true to disable L2 caching. Typically useful in performance testing. + */ + void setDisableL2Cache(boolean disableL2Cache); + + /** + * Return true to use local only L2 cache. Effectively ignore l2 cache plugin like ebean-redis etc. + */ + boolean isLocalOnlyL2Cache(); + + /** + * Force the use of local only L2 cache. Effectively ignore l2 cache plugin like ebean-redis etc. + */ + void setLocalOnlyL2Cache(boolean localOnlyL2Cache); + + /** + * Returns if we use javax.validation.constraints.NotNull + */ + boolean isUseValidationNotNull(); + + /** + * Controls if Ebean should ignore &x64;javax.validation.contstraints.NotNull or + * &x64;jakarta.validation.contstraints.NotNull + * with respect to generating a NOT NULL column. + *

+ * Normally when Ebean sees javax NotNull annotation it means that column is defined as NOT NULL. + * 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); + + /** + * Return true if L2 cache notification should run in the foreground. + */ + boolean isNotifyL2CacheInForeground(); + + /** + * Set this to true to run L2 cache notification in the foreground. + *

+ * In general we don't want to do that as when we use a distributed cache (like Ignite, Hazelcast etc) + * 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); + + /** + * Return the time to live for ebean's internal query plan. + */ + int getQueryPlanTTLSeconds(); + + /** + * Set the time to live for ebean's internal query plan. + *

+ * 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); + + /** + * Create a new PlatformConfig based of the one held but with overridden properties by reading + * properties with the given path and prefix. + *

+ * Typically used in Db Migration generation for many platform targets that might have different + * configuration for IdType, UUID, quoted identifiers etc. + * + * @param propertiesPath The properties path used for loading and setting properties + * @param platformPrefix The prefix used for loading and setting properties + * @return A copy of the PlatformConfig with overridden properties + */ + PlatformConfig newPlatformConfig(String propertiesPath, String platformPrefix); + + /** + * Add a mapping location to search for xml mapping via class path search. + */ + void addMappingLocation(String mappingLocation); + + /** + * Return mapping locations to search for xml mapping via class path search. + */ + List getMappingLocations(); + + /** + * 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); + + /** + * When false we need explicit @GeneratedValue mapping to assign + * Identity or Sequence generated values. When true Id properties are automatically + * assigned Identity or Sequence without the GeneratedValue mapping. + */ + boolean isIdGeneratorAutomatic(); + + /** + * 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); + + /** + * Return true if query plan capture is enabled. + */ + boolean isQueryPlanEnable(); + + /** + * Set to true to enable query plan capture. + */ + void setQueryPlanEnable(boolean queryPlanEnable); + + /** + * Return the query plan collection threshold in microseconds. + */ + long getQueryPlanThresholdMicros(); + + /** + * Set the query plan collection threshold in microseconds. + *

+ * 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); + + /** + * Return true if periodic capture of query plans is enabled. + */ + boolean isQueryPlanCapture(); + + /** + * Set to true to turn on periodic capture of query plans. + */ + void setQueryPlanCapture(boolean queryPlanCapture); + + /** + * Return the frequency to capture query plans. + */ + long getQueryPlanCapturePeriodSecs(); + + /** + * Set the frequency in seconds to capture query plans. + */ + void setQueryPlanCapturePeriodSecs(long queryPlanCapturePeriodSecs); + + /** + * Return the time after which a capture query plans request will + * stop capturing more query plans. + *

+ * Effectively this controls the amount of load/time we want to + * allow for query plan capture. + */ + long getQueryPlanCaptureMaxTimeMillis(); + + /** + * Set the time after which a capture query plans request will + * stop capturing more query plans. + *

+ * Effectively this controls the amount of load/time we want to + * allow for query plan capture. + */ + void setQueryPlanCaptureMaxTimeMillis(long queryPlanCaptureMaxTimeMillis); + + /** + * Return the max number of query plans captured per request. + */ + int getQueryPlanCaptureMaxCount(); + + /** + * Set the max number of query plans captured per request. + */ + void setQueryPlanCaptureMaxCount(int queryPlanCaptureMaxCount); + + /** + * Return the listener used to process captured query plans. + */ + QueryPlanListener getQueryPlanListener(); + + /** + * Set the listener used to process captured query plans. + */ + void setQueryPlanListener(QueryPlanListener queryPlanListener); + + /** + * Return true if metrics should be dumped when the server is shutdown. + */ + boolean isDumpMetricsOnShutdown(); + + /** + * Set to true if metrics should be dumped when the server is shutdown. + */ + void setDumpMetricsOnShutdown(boolean dumpMetricsOnShutdown); + + /** + * Return the options for dumping metrics. + */ + String getDumpMetricsOptions(); + + /** + * Include 'sql' or 'hash' in options such that they are included in the output. + * + * @param dumpMetricsOptions Example "sql,hash", "sql" + */ + void setDumpMetricsOptions(String dumpMetricsOptions); + + /** + * Return true if entity classes should be loaded and registered via EntityClassRegister. + *

+ * When false we either register entity classes via application code or use classpath + * scanning to find and register entity classes. + */ + boolean isLoadModuleInfo(); + + /** + * @deprecated - migrate to {@link #isLoadModuleInfo()}. + */ + @Deprecated(forRemoval = true) + boolean isAutoLoadModuleInfo(); + + /** + * 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). + * This is on by default and setting this to false turns it off. + */ + void setLoadModuleInfo(boolean loadModuleInfo); + + /** + * Return the naming convention to apply to metrics names. + */ + Function getMetricNaming(); + + /** + * Set the naming convention to apply to metrics names. + */ + void setMetricNaming(Function metricNaming); +} diff --git a/ebean-api/src/main/java/io/ebean/DatabaseFactory.java b/ebean-api/src/main/java/io/ebean/DatabaseFactory.java index d8d10f13a..a5eb97d2c 100644 --- a/ebean-api/src/main/java/io/ebean/DatabaseFactory.java +++ b/ebean-api/src/main/java/io/ebean/DatabaseFactory.java @@ -1,7 +1,6 @@ package io.ebean; import io.ebean.config.ContainerConfig; -import io.ebean.config.DatabaseConfig; import io.ebean.service.SpiContainer; import io.ebean.service.SpiContainerFactory; @@ -76,7 +75,7 @@ public final class DatabaseFactory { * * } */ - public static Database create(DatabaseConfig config) { + public static Database create(DatabaseBuilder config) { lock.lock(); try { if (config.getName() == null) { @@ -102,7 +101,7 @@ public final class DatabaseFactory { /** * Create using the DatabaseConfig additionally specifying a classLoader to use as the context class loader. */ - public static Database createWithContextClassLoader(DatabaseConfig config, ClassLoader classLoader) { + public static Database createWithContextClassLoader(DatabaseBuilder config, ClassLoader classLoader) { lock.lock(); try { ClassLoader currentContextLoader = Thread.currentThread().getContextClassLoader(); @@ -132,7 +131,7 @@ public final class DatabaseFactory { } } - private static Database createInternal(DatabaseConfig config) { + private static Database createInternal(DatabaseBuilder config) { return container(config.getContainerConfig()).createServer(config); } diff --git a/ebean-api/src/main/java/io/ebean/cache/ServerCacheNotifyPlugin.java b/ebean-api/src/main/java/io/ebean/cache/ServerCacheNotifyPlugin.java index a783cf8e8..104369860 100644 --- a/ebean-api/src/main/java/io/ebean/cache/ServerCacheNotifyPlugin.java +++ b/ebean-api/src/main/java/io/ebean/cache/ServerCacheNotifyPlugin.java @@ -1,6 +1,6 @@ package io.ebean.cache; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; /** * Plugin that provides a ServerCacheNotify implementation. @@ -12,5 +12,5 @@ public interface ServerCacheNotifyPlugin { /** * Create a ServerCacheNotify implementation given the server configuration. */ - ServerCacheNotify create(DatabaseConfig config); + ServerCacheNotify create(DatabaseBuilder config); } diff --git a/ebean-api/src/main/java/io/ebean/cache/ServerCachePlugin.java b/ebean-api/src/main/java/io/ebean/cache/ServerCachePlugin.java index 4050de876..9dc550a2b 100644 --- a/ebean-api/src/main/java/io/ebean/cache/ServerCachePlugin.java +++ b/ebean-api/src/main/java/io/ebean/cache/ServerCachePlugin.java @@ -1,7 +1,7 @@ package io.ebean.cache; import io.ebean.BackgroundExecutor; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; /** * The plugin interface that creates a ServerCacheFactory. @@ -11,5 +11,5 @@ public interface ServerCachePlugin { /** * Create the ServerCacheFactory given the server config and background executor service. */ - ServerCacheFactory create(DatabaseConfig config, BackgroundExecutor executor); + ServerCacheFactory create(DatabaseBuilder config, BackgroundExecutor executor); } diff --git a/ebean-api/src/main/java/io/ebean/config/AutoConfigure.java b/ebean-api/src/main/java/io/ebean/config/AutoConfigure.java index edbb22384..442df816b 100644 --- a/ebean-api/src/main/java/io/ebean/config/AutoConfigure.java +++ b/ebean-api/src/main/java/io/ebean/config/AutoConfigure.java @@ -1,5 +1,7 @@ package io.ebean.config; +import io.ebean.DatabaseBuilder; + /** * Used to provide some automatic configuration early in the creation of a Database. */ @@ -8,11 +10,11 @@ public interface AutoConfigure { /** * Perform configuration for the DatabaseConfig prior to properties load. */ - void preConfigure(DatabaseConfig config); + void preConfigure(DatabaseBuilder config); /** * Provide some configuration the DatabaseConfig prior to server creation but after properties have been applied. */ - void postConfigure(DatabaseConfig config); + void postConfigure(DatabaseBuilder config); } 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 bcd30b7c0..2e3a29d36 100644 --- a/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java +++ b/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java @@ -61,7 +61,7 @@ import java.util.function.Function; * @author rbygrave * @see DatabaseFactory */ -public class DatabaseConfig { +public class DatabaseConfig implements DatabaseBuilder { /** * The Database name. @@ -548,1043 +548,639 @@ public class DatabaseConfig { public DatabaseConfig() { } - /** - * Get the clock used for setting the timestamps (e.g. @UpdatedTimestamp) on objects. - */ + @Override public Clock getClock() { return clock; } - /** - * Set the clock used for setting the timestamps (e.g. @UpdatedTimestamp) on objects. - */ + @Override public void setClock(final Clock clock) { this.clock = clock; } - /** - * Return the slow query time in millis. - */ + @Override public long getSlowQueryMillis() { return slowQueryMillis; } - /** - * Set the slow query time in millis. - */ + @Override public void setSlowQueryMillis(long slowQueryMillis) { this.slowQueryMillis = slowQueryMillis; } - /** - * Return the slow query event listener. - */ + @Override public SlowQueryListener getSlowQueryListener() { return slowQueryListener; } - /** - * Set the slow query event listener. - */ + @Override public void setSlowQueryListener(SlowQueryListener slowQueryListener) { this.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. - */ + @Override public void putServiceObject(String key, Object configObject) { serviceObject.put(key, configObject); } - /** - * 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. - * You can also override some SPI objects that should be used for that Database. Currently, the following - * objects are possible. - *

    - *
  • DataSourceAlertFactory (e.g. add different alert factories for different ebean instances)
  • - *
  • DocStoreFactory
  • - *
  • SlowQueryListener (e.g. add custom query listener for a certain ebean instance)
  • - *
  • ServerCacheNotifyPlugin
  • - *
- */ + @Override public void putServiceObject(Class iface, T configObject) { serviceObject.put(serviceObjectKey(iface), configObject); } - /** - * Return the service object given the key. - */ + @Override public Object getServiceObject(String key) { return serviceObject.get(key); } - /** - * Put a service object into configuration such that it can be used by ebean or a plugin. - * - *
{@code
-   *
-   *   JedisPool jedisPool = ..
-   *
-   *   config.putServiceObject(jedisPool);
-   *
-   * }
- */ + @Override public void putServiceObject(Object configObject) { String key = serviceObjectKey(configObject); serviceObject.put(key, configObject); } - private String serviceObjectKey(Object configObject) { - return serviceObjectKey(configObject.getClass()); - } - - private String serviceObjectKey(Class cls) { - String simpleName = cls.getSimpleName(); - return Character.toLowerCase(simpleName.charAt(0)) + simpleName.substring(1); - } - - /** - * Used by ebean or plugins to obtain service objects. - * - *
{@code
-   *
-   *   JedisPool jedisPool = config.getServiceObject(JedisPool.class);
-   *
-   * }
- * - * @param cls The type of the service object to obtain - * @return The service object given the class type - */ + @Override @SuppressWarnings("unchecked") public

P getServiceObject(Class

cls) { return (P) serviceObject.get(serviceObjectKey(cls)); } - /** - * Return the Jackson JsonFactory to use. - *

- * If not set a default implementation will be used. - */ + @Override public JsonFactory getJsonFactory() { return jsonFactory; } - /** - * Set the Jackson JsonFactory to use. - *

- * If not set a default implementation will be used. - */ + @Override public void setJsonFactory(JsonFactory jsonFactory) { this.jsonFactory = jsonFactory; } - /** - * Return the JSON format used for DateTime types. - */ + @Override public JsonConfig.DateTime getJsonDateTime() { return jsonDateTime; } - /** - * Set the JSON format to use for DateTime types. - */ + @Override public void setJsonDateTime(JsonConfig.DateTime jsonDateTime) { this.jsonDateTime = jsonDateTime; } - /** - * Return the JSON format used for Date types. - */ + @Override public JsonConfig.Date getJsonDate() { return jsonDate; } - /** - * Set the JSON format to use for Date types. - */ + @Override public void setJsonDate(JsonConfig.Date jsonDate) { this.jsonDate = jsonDate; } - /** - * Return the JSON include mode used when writing JSON. - */ + @Override public JsonConfig.Include getJsonInclude() { return jsonInclude; } - /** - * 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. - */ + @Override public void setJsonInclude(JsonConfig.Include jsonInclude) { this.jsonInclude = jsonInclude; } - /** - * Return the default MutableDetection to use with {@code @DbJson} using Jackson. - * - * @see DbJson#mutationDetection() - */ + @Override public MutationDetection getJsonMutationDetection() { return jsonMutationDetection; } - /** - * Set the default MutableDetection to use with {@code @DbJson} using Jackson. - * - * @see DbJson#mutationDetection() - */ + @Override public void setJsonMutationDetection(MutationDetection jsonMutationDetection) { this.jsonMutationDetection = jsonMutationDetection; } - /** - * Return the name of the Database. - */ + @Override public String getName() { return name; } - /** - * Set the name of the Database. - */ + @Override public void setName(String name) { this.name = name; } - /** - * Return the container / clustering configuration. - *

- * The container holds all the Database instances and provides clustering communication - * services to all the Database instances. - */ + @Override public ContainerConfig getContainerConfig() { return containerConfig; } - /** - * Set the container / clustering configuration. - *

- * The container holds all the Database instances and provides clustering communication - * services to all the Database instances. - */ + @Override public void setContainerConfig(ContainerConfig containerConfig) { this.containerConfig = containerConfig; } - /** - * Return true if this server should be registered with the Ebean singleton - * when it is created. - *

- * By default this is set to true. - */ + @Override public boolean isRegister() { return register; } - /** - * 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. - */ + @Override public void setRegister(boolean register) { this.register = register; } - /** - * Return true if this server should be registered as the "default" server - * with the Ebean singleton. - *

- * This is only used when {@link #setRegister(boolean)} is also true. - */ + @Override public boolean isDefaultServer() { return defaultServer; } - /** - * 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. - */ + @Override public void setDefaultServer(boolean defaultServer) { this.defaultServer = defaultServer; } - /** - * Return the CurrentUserProvider. This is used to populate @WhoCreated, @WhoModified and - * support other audit features (who executed a query etc). - */ + @Override public CurrentUserProvider getCurrentUserProvider() { return currentUserProvider; } - /** - * Set the CurrentUserProvider. This is used to populate @WhoCreated, @WhoModified and - * support other audit features (who executed a query etc). - */ + @Override public void setCurrentUserProvider(CurrentUserProvider currentUserProvider) { this.currentUserProvider = currentUserProvider; } - /** - * Return the tenancy mode used. - */ + @Override public TenantMode getTenantMode() { return tenantMode; } - /** - * Set the tenancy mode to use. - */ + @Override public void setTenantMode(TenantMode tenantMode) { this.tenantMode = tenantMode; } - /** - * Return the column name used for TenantMode.PARTITION. - */ + @Override public String getTenantPartitionColumn() { return tenantPartitionColumn; } - /** - * Set the column name used for TenantMode.PARTITION. - */ + @Override public void setTenantPartitionColumn(String tenantPartitionColumn) { this.tenantPartitionColumn = tenantPartitionColumn; } - /** - * Return the current tenant provider. - */ + @Override public CurrentTenantProvider getCurrentTenantProvider() { return currentTenantProvider; } - /** - * Set the current tenant provider. - */ + @Override public void setCurrentTenantProvider(CurrentTenantProvider currentTenantProvider) { this.currentTenantProvider = currentTenantProvider; } - /** - * Return the tenancy datasource provider. - */ + @Override public TenantDataSourceProvider getTenantDataSourceProvider() { return tenantDataSourceProvider; } - /** - * Set the tenancy datasource provider. - */ + @Override public void setTenantDataSourceProvider(TenantDataSourceProvider tenantDataSourceProvider) { this.tenantDataSourceProvider = tenantDataSourceProvider; } - /** - * Return the tenancy schema provider. - */ + @Override public TenantSchemaProvider getTenantSchemaProvider() { return tenantSchemaProvider; } - /** - * Set the tenancy schema provider. - */ + @Override public void setTenantSchemaProvider(TenantSchemaProvider tenantSchemaProvider) { this.tenantSchemaProvider = tenantSchemaProvider; } - /** - * Return the tenancy catalog provider. - */ + @Override public TenantCatalogProvider getTenantCatalogProvider() { return tenantCatalogProvider; } - /** - * Set the tenancy catalog provider. - */ + @Override public void setTenantCatalogProvider(TenantCatalogProvider tenantCatalogProvider) { this.tenantCatalogProvider = tenantCatalogProvider; } - /** - * Return true if dirty beans are automatically persisted. - */ + @Override public boolean isAutoPersistUpdates() { return autoPersistUpdates; } - /** - * Set to true if dirty beans are automatically persisted. - */ + @Override public void setAutoPersistUpdates(boolean autoPersistUpdates) { this.autoPersistUpdates = autoPersistUpdates; } - /** - * Return the PersistBatch mode to use by default 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. - */ + @Override public PersistBatch getPersistBatch() { return persistBatch; } - /** - * 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. - */ + @Override public void setPersistBatch(PersistBatch persistBatch) { this.persistBatch = persistBatch; } - /** - * Return the JDBC batch mode to use per save(), delete(), insert() or update() request. - *

- * This makes sense when a save() or delete() cascades and executes multiple child statements. The best case - * 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. - */ + @Override public PersistBatch getPersistBatchOnCascade() { return persistBatchOnCascade; } - /** - * 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. - */ + @Override public void setPersistBatchOnCascade(PersistBatch persistBatchOnCascade) { this.persistBatchOnCascade = 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)} - */ + @Override public void setPersistBatching(boolean persistBatching) { this.persistBatch = (persistBatching) ? PersistBatch.ALL : PersistBatch.NONE; } - /** - * Return the batch size used for JDBC batching. This defaults to 20. - */ + @Override public int getPersistBatchSize() { return persistBatchSize; } - /** - * 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) - */ + @Override public void setPersistBatchSize(int persistBatchSize) { this.persistBatchSize = persistBatchSize; } - /** - * Gets the query batch size. This defaults to 100. - * - * @return the query batch size - */ + @Override public int getQueryBatchSize() { return queryBatchSize; } - /** - * Sets the query batch size. This defaults to 100. - * - * @param queryBatchSize the new query batch size - */ + @Override public void setQueryBatchSize(int queryBatchSize) { this.queryBatchSize = queryBatchSize; } + @Override public EnumType getDefaultEnumType() { return defaultEnumType; } + @Override public void setDefaultEnumType(EnumType defaultEnumType) { this.defaultEnumType = defaultEnumType; } - /** - * Return true if lazy loading is disabled on queries by default. - */ + @Override public boolean isDisableLazyLoading() { return disableLazyLoading; } - /** - * Set to true to disable lazy loading by default. - *

- * It can be turned on per query via {@link Query#setDisableLazyLoading(boolean)}. - */ + @Override public void setDisableLazyLoading(boolean disableLazyLoading) { this.disableLazyLoading = disableLazyLoading; } - /** - * Return the default batch size for lazy loading of beans and collections. - */ + @Override public int getLazyLoadBatchSize() { return lazyLoadBatchSize; } - /** - * 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. - */ + @Override public void setLazyLoadBatchSize(int lazyLoadBatchSize) { this.lazyLoadBatchSize = lazyLoadBatchSize; } - /** - * Set the number of sequences to fetch/preallocate when using DB sequences. - *

- * This is a performance optimisation to reduce the number times Ebean - * requests a sequence to be used as an Id for a bean (aka reduce network - * chatter). - */ + @Override public void setDatabaseSequenceBatchSize(int databaseSequenceBatchSize) { platformConfig.setDatabaseSequenceBatchSize(databaseSequenceBatchSize); } - /** - * Return the default JDBC fetchSize hint for findList queries. - */ + @Override public int getJdbcFetchSizeFindList() { return jdbcFetchSizeFindList; } - /** - * Set the default JDBC fetchSize hint for findList queries. - */ + @Override public void setJdbcFetchSizeFindList(int jdbcFetchSizeFindList) { this.jdbcFetchSizeFindList = jdbcFetchSizeFindList; } - /** - * Return the default JDBC fetchSize hint for findEach/findEachWhile queries. - */ + @Override public int getJdbcFetchSizeFindEach() { return jdbcFetchSizeFindEach; } - /** - * Set the default JDBC fetchSize hint for findEach/findEachWhile queries. - */ + @Override public void setJdbcFetchSizeFindEach(int jdbcFetchSizeFindEach) { this.jdbcFetchSizeFindEach = jdbcFetchSizeFindEach; } - /** - * Return the ChangeLogPrepare. - *

- * This is used to set user context information to the ChangeSet in the - * foreground thread prior to the logging occurring in a background thread. - */ + @Override public ChangeLogPrepare getChangeLogPrepare() { return changeLogPrepare; } - /** - * Set the ChangeLogPrepare. - *

- * This is used to set user context information to the ChangeSet in the - * foreground thread prior to the logging occurring in a background thread. - */ + @Override public void setChangeLogPrepare(ChangeLogPrepare changeLogPrepare) { this.changeLogPrepare = changeLogPrepare; } - /** - * Return the ChangeLogListener which actually performs the logging of change sets - * in the background. - */ + @Override public ChangeLogListener getChangeLogListener() { return changeLogListener; } - /** - * Set the ChangeLogListener which actually performs the logging of change sets - * in the background. - */ + @Override public void setChangeLogListener(ChangeLogListener changeLogListener) { this.changeLogListener = changeLogListener; } - /** - * Return 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. - */ + @Override public ChangeLogRegister getChangeLogRegister() { return changeLogRegister; } - /** - * 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. - */ + @Override public void setChangeLogRegister(ChangeLogRegister changeLogRegister) { this.changeLogRegister = changeLogRegister; } - /** - * Return true if inserts should be included in the change log by default. - */ + @Override public boolean isChangeLogIncludeInserts() { return changeLogIncludeInserts; } - /** - * Set if inserts should be included in the change log by default. - */ + @Override public void setChangeLogIncludeInserts(boolean changeLogIncludeInserts) { this.changeLogIncludeInserts = changeLogIncludeInserts; } - /** - * Return true (default) if the changelog should be written async. - */ + @Override public boolean isChangeLogAsync() { return changeLogAsync; } - /** - * Sets if the changelog should be written async (default = true). - */ + @Override public void setChangeLogAsync(boolean changeLogAsync) { this.changeLogAsync = changeLogAsync; } - /** - * Return the ReadAuditLogger to use. - */ + @Override public ReadAuditLogger getReadAuditLogger() { return readAuditLogger; } - /** - * 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). - */ + @Override public void setReadAuditLogger(ReadAuditLogger readAuditLogger) { this.readAuditLogger = readAuditLogger; } - /** - * Return the ReadAuditPrepare to use. - */ + @Override public ReadAuditPrepare getReadAuditPrepare() { return readAuditPrepare; } - /** - * Set the ReadAuditPrepare to use. - *

- * It is expected that an implementation is used that read user context information - * (user id, user ip address etc) and sets it on the ReadEvent bean before it is sent - * to the ReadAuditLogger. - */ + @Override public void setReadAuditPrepare(ReadAuditPrepare readAuditPrepare) { this.readAuditPrepare = readAuditPrepare; } - /** - * Return the configuration for profiling. - */ + @Override public ProfilingConfig getProfilingConfig() { return profilingConfig; } - /** - * Set the configuration for profiling. - */ + @Override public void setProfilingConfig(ProfilingConfig profilingConfig) { this.profilingConfig = profilingConfig; } - /** - * Return the DB schema to use. - */ + @Override public String getDbSchema() { return dbSchema; } - /** - * 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
  • - *
- */ + @Override public void setDbSchema(String dbSchema) { this.dbSchema = dbSchema; } - /** - * Return the Geometry SRID. - */ + @Override public int getGeometrySRID() { return platformConfig.getGeometrySRID(); } - /** - * Set the Geometry SRID. - */ + @Override public void setGeometrySRID(int geometrySRID) { platformConfig.setGeometrySRID(geometrySRID); } - /** - * Return the time zone to use when reading/writing Timestamps via JDBC. - *

- * When set a Calendar object is used in JDBC calls when reading/writing Timestamp objects. - */ + @Override public String getDataTimeZone() { return System.getProperty("ebean.dataTimeZone", dataTimeZone); } - /** - * Set the time zone to use when reading/writing Timestamps via JDBC. - */ + @Override public void setDataTimeZone(String dataTimeZone) { this.dataTimeZone = dataTimeZone; } - /** - * Return 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. - */ + @Override public String getAsOfViewSuffix() { return asOfViewSuffix; } - /** - * 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. - */ + @Override public void setAsOfViewSuffix(String asOfViewSuffix) { this.asOfViewSuffix = asOfViewSuffix; } - /** - * Return the database column used to support history and 'As of' queries. This column is a timestamp range - * or equivalent. - */ + @Override public String getAsOfSysPeriod() { return asOfSysPeriod; } - /** - * Set the database column used to support history and 'As of' queries. This column is a timestamp range - * or equivalent. - */ + @Override public void setAsOfSysPeriod(String asOfSysPeriod) { this.asOfSysPeriod = asOfSysPeriod; } - /** - * Return the history table suffix (defaults to _history). - */ + @Override public String getHistoryTableSuffix() { return historyTableSuffix; } - /** - * Set the history table suffix. - */ + @Override public void setHistoryTableSuffix(String historyTableSuffix) { this.historyTableSuffix = historyTableSuffix; } - /** - * Return true if we are running in a JTA Transaction manager. - */ + @Override public boolean isUseJtaTransactionManager() { return useJtaTransactionManager; } - /** - * Set to true if we are running in a JTA Transaction manager. - */ + @Override public void setUseJtaTransactionManager(boolean useJtaTransactionManager) { this.useJtaTransactionManager = useJtaTransactionManager; } - /** - * Return the external transaction manager. - */ + @Override public ExternalTransactionManager getExternalTransactionManager() { return externalTransactionManager; } - /** - * Set the external transaction manager. - */ + @Override public void setExternalTransactionManager(ExternalTransactionManager externalTransactionManager) { this.externalTransactionManager = externalTransactionManager; } - /** - * Return the ServerCachePlugin. - */ + @Override public ServerCachePlugin getServerCachePlugin() { return serverCachePlugin; } - /** - * Set the ServerCachePlugin to use. - */ + @Override public void setServerCachePlugin(ServerCachePlugin serverCachePlugin) { this.serverCachePlugin = serverCachePlugin; } - /** - * Return true if LOB's should default to fetch eager. - * By default this is set to false and LOB's must be explicitly fetched. - */ + @Override public boolean isEagerFetchLobs() { return eagerFetchLobs; } - /** - * 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. - */ + @Override public void setEagerFetchLobs(boolean eagerFetchLobs) { this.eagerFetchLobs = eagerFetchLobs; } - /** - * Return the max call stack to use for origin location. - */ + @Override public int getMaxCallStack() { return maxCallStack; } - /** - * Set the max call stack to use for origin location. - */ + @Override public void setMaxCallStack(int maxCallStack) { this.maxCallStack = maxCallStack; } - /** - * Return true if transactions should rollback on checked exceptions. - */ + @Override public boolean isTransactionRollbackOnChecked() { return transactionRollbackOnChecked; } - /** - * Set to true if transactions should by default rollback on checked exceptions. - */ + @Override public void setTransactionRollbackOnChecked(boolean transactionRollbackOnChecked) { this.transactionRollbackOnChecked = transactionRollbackOnChecked; } - /** - * Return the Background executor schedule pool size. Defaults to 1. - */ + @Override public int getBackgroundExecutorSchedulePoolSize() { return backgroundExecutorSchedulePoolSize; } - /** - * Set the Background executor schedule pool size. - */ + @Override public void setBackgroundExecutorSchedulePoolSize(int backgroundExecutorSchedulePoolSize) { this.backgroundExecutorSchedulePoolSize = backgroundExecutorSchedulePoolSize; } - /** - * Return the Background executor shutdown seconds. This is the time allowed for the pool to shutdown nicely - * before it is forced shutdown. - */ + @Override public int getBackgroundExecutorShutdownSecs() { return backgroundExecutorShutdownSecs; } - /** - * Set the Background executor shutdown seconds. This is the time allowed for the pool to shutdown nicely - * before it is forced shutdown. - */ + @Override public void setBackgroundExecutorShutdownSecs(int backgroundExecutorShutdownSecs) { this.backgroundExecutorShutdownSecs = backgroundExecutorShutdownSecs; } - /** - * Return the background executor wrapper. - */ + @Override public BackgroundExecutorWrapper getBackgroundExecutorWrapper() { return backgroundExecutorWrapper; } - /** - * Sets the background executor wrapper. The wrapper is used when a task is sent to background and should copy the thread-locals. - */ + @Override public void setBackgroundExecutorWrapper(BackgroundExecutorWrapper backgroundExecutorWrapper) { this.backgroundExecutorWrapper = backgroundExecutorWrapper; } - /** - * Return the L2 cache default max size. - */ + @Override public int getCacheMaxSize() { return cacheMaxSize; } - /** - * Set the L2 cache default max size. - */ + @Override public void setCacheMaxSize(int cacheMaxSize) { this.cacheMaxSize = cacheMaxSize; } - /** - * Return the L2 cache default max idle time in seconds. - */ + @Override public int getCacheMaxIdleTime() { return cacheMaxIdleTime; } - /** - * Set the L2 cache default max idle time in seconds. - */ + @Override public void setCacheMaxIdleTime(int cacheMaxIdleTime) { this.cacheMaxIdleTime = cacheMaxIdleTime; } - /** - * Return the L2 cache default max time to live in seconds. - */ + @Override public int getCacheMaxTimeToLive() { return cacheMaxTimeToLive; } - /** - * Set the L2 cache default max time to live in seconds. - */ + @Override public void setCacheMaxTimeToLive(int cacheMaxTimeToLive) { this.cacheMaxTimeToLive = cacheMaxTimeToLive; } - /** - * Return the L2 query cache default max size. - */ + @Override public int getQueryCacheMaxSize() { return queryCacheMaxSize; } - /** - * Set the L2 query cache default max size. - */ + @Override public void setQueryCacheMaxSize(int queryCacheMaxSize) { this.queryCacheMaxSize = queryCacheMaxSize; } - /** - * Return the L2 query cache default max idle time in seconds. - */ + @Override public int getQueryCacheMaxIdleTime() { return queryCacheMaxIdleTime; } - /** - * Set the L2 query cache default max idle time in seconds. - */ + @Override public void setQueryCacheMaxIdleTime(int queryCacheMaxIdleTime) { this.queryCacheMaxIdleTime = queryCacheMaxIdleTime; } - /** - * Return the L2 query cache default max time to live in seconds. - */ + @Override public int getQueryCacheMaxTimeToLive() { return queryCacheMaxTimeToLive; } - /** - * Set the L2 query cache default max time to live in seconds. - */ + @Override public void setQueryCacheMaxTimeToLive(int queryCacheMaxTimeToLive) { this.queryCacheMaxTimeToLive = queryCacheMaxTimeToLive; } - /** - * Return the NamingConvention. - *

- * If none has been set the default UnderscoreNamingConvention is used. - */ + @Override public NamingConvention getNamingConvention() { return namingConvention; } - /** - * Set the NamingConvention. - *

- * If none is set the default UnderscoreNamingConvention is used. - */ + @Override public void setNamingConvention(NamingConvention namingConvention) { this.namingConvention = namingConvention; } - /** - * Return true if all DB column and table names should use quoted identifiers. - */ + @Override public boolean isAllQuotedIdentifiers() { return platformConfig.isAllQuotedIdentifiers(); } - /** - * Set to true if all DB column and table names should use quoted identifiers. - *

- * For Postgres pgjdbc version 42.3.0 should be used with datasource property - * quoteReturningIdentifiers set to false (refer #2303). - */ + @Override public void setAllQuotedIdentifiers(boolean allQuotedIdentifiers) { platformConfig.setAllQuotedIdentifiers(allQuotedIdentifiers); if (allQuotedIdentifiers) { @@ -1599,423 +1195,242 @@ public class DatabaseConfig { } } - /** - * Return true if this Database is a Document store only instance (has no JDBC DB). - */ + @Override public boolean isDocStoreOnly() { return docStoreOnly; } - /** - * Set to true if this Database is Document store only instance (has no JDBC DB). - */ + @Override public void setDocStoreOnly(boolean docStoreOnly) { this.docStoreOnly = docStoreOnly; } - /** - * Return the configuration for the ElasticSearch integration. - */ + @Override public DocStoreConfig getDocStoreConfig() { return docStoreConfig; } - /** - * Set the configuration for the ElasticSearch integration. - */ + @Override public void setDocStoreConfig(DocStoreConfig docStoreConfig) { this.docStoreConfig = docStoreConfig; } - /** - * Return the constraint naming convention used in DDL generation. - */ + @Override public DbConstraintNaming getConstraintNaming() { return platformConfig.getConstraintNaming(); } - /** - * Set the constraint naming convention used in DDL generation. - */ + @Override public void setConstraintNaming(DbConstraintNaming constraintNaming) { platformConfig.setConstraintNaming(constraintNaming); } - /** - * Return the configuration for AutoTune. - */ + @Override public AutoTuneConfig getAutoTuneConfig() { return autoTuneConfig; } - /** - * Set the configuration for AutoTune. - */ + @Override public void setAutoTuneConfig(AutoTuneConfig autoTuneConfig) { this.autoTuneConfig = autoTuneConfig; } - /** - * Return true if the startup DataSource check should be skipped. - */ + @Override public boolean skipDataSourceCheck() { return skipDataSourceCheck; } - /** - * Set to true to skip the startup DataSource check. - */ + @Override public void setSkipDataSourceCheck(boolean skipDataSourceCheck) { this.skipDataSourceCheck = skipDataSourceCheck; } - /** - * Return the DataSource. - */ + @Override public DataSource getDataSource() { return dataSource; } - /** - * Set a DataSource. - */ + @Override public void setDataSource(DataSource dataSource) { this.dataSource = dataSource; } - /** - * Return the read only DataSource. - */ + @Override public DataSource getReadOnlyDataSource() { return readOnlyDataSource; } - /** - * Set the read only DataSource. - *

- * Note that the DataSource is expected to use AutoCommit true mode avoiding the need - * for explicit commit (or rollback). - *

- * 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. - */ + @Override public void setReadOnlyDataSource(DataSource readOnlyDataSource) { this.readOnlyDataSource = readOnlyDataSource; } - /** - * Return the configuration to build a DataSource using Ebean's own DataSource - * implementation. - */ + @Override public DataSourceBuilder getDataSourceConfig() { return dataSourceConfig; } - /** - * Set the configuration required to build a DataSource using Ebean's own - * DataSource implementation. - */ + @Override public void setDataSourceConfig(DataSourceBuilder dataSourceConfig) { this.dataSourceConfig = dataSourceConfig; } - /** - * Return true if Ebean should create a DataSource for use with implicit read only transactions. - */ + @Override public boolean isAutoReadOnlyDataSource() { return autoReadOnlyDataSource; } - /** - * Set to true if Ebean should create a DataSource for use with implicit read only transactions. - */ + @Override public void setAutoReadOnlyDataSource(boolean autoReadOnlyDataSource) { this.autoReadOnlyDataSource = autoReadOnlyDataSource; } - /** - * Return the configuration for the read only DataSource. - *

- * This is only used if autoReadOnlyDataSource is true. - *

- * The driver, url, username and password default to the configuration for the main DataSource if they are not - * set on this configuration. This means there is actually no need to set any configuration here and we only - * set configuration for url, username and password etc if it is different from the main DataSource. - */ + @Override public DataSourceBuilder getReadOnlyDataSourceConfig() { return readOnlyDataSourceConfig; } - /** - * Set the configuration for the read only DataSource. - */ + @Override public void setReadOnlyDataSourceConfig(DataSourceBuilder readOnlyDataSourceConfig) { this.readOnlyDataSourceConfig = readOnlyDataSourceConfig; } - /** - * Return a value used to represent TRUE in the database. - *

- * This is used for databases that do not support boolean natively. - *

- * The value returned is either a Integer or a String (e.g. "1", or "T"). - */ + @Override public String getDatabaseBooleanTrue() { return platformConfig.getDatabaseBooleanTrue(); } - /** - * Set the value to represent TRUE in the database. - *

- * This is used for databases that do not support boolean natively. - *

- * The value set is either a Integer or a String (e.g. "1", or "T"). - */ + @Override public void setDatabaseBooleanTrue(String databaseTrue) { platformConfig.setDatabaseBooleanTrue(databaseTrue); } - /** - * Return a value used to represent FALSE in the database. - *

- * This is used for databases that do not support boolean natively. - *

- * The value returned is either a Integer or a String (e.g. "0", or "F"). - */ + @Override public String getDatabaseBooleanFalse() { return platformConfig.getDatabaseBooleanFalse(); } - /** - * Set the value to represent FALSE in the database. - *

- * This is used for databases that do not support boolean natively. - *

- * The value set is either a Integer or a String (e.g. "0", or "F"). - */ + @Override public void setDatabaseBooleanFalse(String databaseFalse) { this.platformConfig.setDatabaseBooleanFalse(databaseFalse); } - /** - * Return the number of DB sequence values that should be preallocated. - */ + @Override public int getDatabaseSequenceBatchSize() { return platformConfig.getDatabaseSequenceBatchSize(); } - /** - * Set the number of DB sequence values that should be preallocated and cached - * by Ebean. - *

- * This is only used for DB's that use sequences and is a performance - * optimisation. This reduces the number of times Ebean needs to get a - * sequence value from the Database reducing network chatter. - *

- * By default this value is 10 so when we need another Id (and don't have one - * in our cache) Ebean will fetch 10 id's from the database. Note that when - * the cache drops to have full (which is 5 by default) Ebean will fetch - * another batch of Id's in a background thread. - */ + @Override public void setDatabaseSequenceBatch(int databaseSequenceBatchSize) { this.platformConfig.setDatabaseSequenceBatchSize(databaseSequenceBatchSize); } - /** - * Return the database platform name (can be null). - *

- * If null then the platform is determined automatically via the JDBC driver - * information. - */ + @Override public String getDatabasePlatformName() { return databasePlatformName; } - /** - * Explicitly set the database platform name - *

- * If none is set then the platform is determined automatically via the JDBC - * driver information. - *

- * This can be used when the Database Platform can not be automatically - * detected from the JDBC driver (possibly 3rd party JDBC driver). It is also - * useful when you want to do offline DDL generation for a database platform - * that you don't have access to. - *

- * Values are oracle, h2, postgres, mysql, sqlserver16, sqlserver17. - */ + @Override public void setDatabasePlatformName(String databasePlatformName) { this.databasePlatformName = databasePlatformName; } - /** - * Return the database platform to use for this database. - */ + @Override public DatabasePlatform getDatabasePlatform() { return databasePlatform; } - /** - * Explicitly set the database platform to use. - *

- * If none is set then the platform is determined via the databasePlatformName - * or automatically via the JDBC driver information. - */ + @Override public void setDatabasePlatform(DatabasePlatform databasePlatform) { this.databasePlatform = databasePlatform; } - /** - * Return the preferred DB platform IdType. - */ + @Override public IdType getIdType() { return platformConfig.getIdType(); } - /** - * Set the preferred DB platform IdType. - */ + @Override public void setIdType(IdType idType) { this.platformConfig.setIdType(idType); } - /** - * Return the EncryptKeyManager. - */ + @Override public EncryptKeyManager getEncryptKeyManager() { return encryptKeyManager; } - /** - * Set the EncryptKeyManager. - *

- * This is required when you want to use encrypted properties. - *

- * You can also set this in ebean.proprerties: - *

- *

{@code
-   * # set via ebean.properties
-   * ebean.encryptKeyManager=org.avaje.tests.basic.encrypt.BasicEncyptKeyManager
-   * }
- */ + @Override public void setEncryptKeyManager(EncryptKeyManager encryptKeyManager) { this.encryptKeyManager = encryptKeyManager; } - /** - * Return the EncryptDeployManager. - *

- * This is optionally used to programmatically define which columns are - * encrypted instead of using the {@link Encrypted} Annotation. - */ + @Override public EncryptDeployManager getEncryptDeployManager() { return encryptDeployManager; } - /** - * Set the EncryptDeployManager. - *

- * This is optionally used to programmatically define which columns are - * encrypted instead of using the {@link Encrypted} Annotation. - */ + @Override public void setEncryptDeployManager(EncryptDeployManager encryptDeployManager) { this.encryptDeployManager = encryptDeployManager; } - /** - * Return the Encryptor used to encrypt data on the java client side (as - * opposed to DB encryption functions). - */ + @Override public Encryptor getEncryptor() { return encryptor; } - /** - * Set the Encryptor used to encrypt data on the java client side (as opposed - * to DB encryption functions). - *

- * Ebean has a default implementation that it will use if you do not set your - * own Encryptor implementation. - */ + @Override public void setEncryptor(Encryptor encryptor) { this.encryptor = encryptor; } - /** - * Return true if the Database instance should be created in offline mode. - */ + @Override public boolean isDbOffline() { return dbOffline; } - /** - * Set to true if the Database instance should be created in offline mode. - *

- * Typically used to create an Database instance for DDL Migration generation - * without requiring a real DataSource / Database to connect to. - */ + @Override public void setDbOffline(boolean dbOffline) { this.dbOffline = dbOffline; } - /** - * Return the DbEncrypt used to encrypt and decrypt properties. - *

- * Note that if this is not set then the DbPlatform may already have a - * DbEncrypt set and that will be used. - */ + @Override public DbEncrypt getDbEncrypt() { return dbEncrypt; } - /** - * Set the DbEncrypt used to encrypt and decrypt properties. - *

- * 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) - */ + @Override public void setDbEncrypt(DbEncrypt dbEncrypt) { this.dbEncrypt = dbEncrypt; } - /** - * Return the configuration for DB types (such as UUID and custom mappings). - */ + @Override public PlatformConfig getPlatformConfig() { return platformConfig; } - /** - * Set the configuration for DB platform (such as UUID and custom mappings). - */ + @Override public void setPlatformConfig(PlatformConfig platformConfig) { this.platformConfig = platformConfig; } - /** - * Set the DB type used to store UUID. - */ + @Override public void setDbUuid(PlatformConfig.DbUuid dbUuid) { this.platformConfig.setDbUuid(dbUuid); } - /** - * Returns the UUID version mode. - */ + @Override public UuidVersion getUuidVersion() { return uuidVersion; } - /** - * Sets the UUID version mode. - */ + @Override public void setUuidVersion(UuidVersion uuidVersion) { this.uuidVersion = uuidVersion; } - /** - * Return the UUID state file. - */ + @Override public String getUuidStateFile() { if (uuidStateFile == null || uuidStateFile.isEmpty()) { // by default, add servername... @@ -2029,194 +1444,119 @@ public class DatabaseConfig { return uuidStateFile; } - /** - * Set the UUID state file. - */ + @Override public void setUuidStateFile(String uuidStateFile) { this.uuidStateFile = uuidStateFile; } - /** - * Returns the V1-UUID-NodeId - */ + @Override public String getUuidNodeId() { return uuidNodeId; } - /** - * Sets the V1-UUID-NodeId. - */ + @Override public void setUuidNodeId(String uuidNodeId) { this.uuidNodeId = uuidNodeId; } - /** - * Return true if LocalTime should be persisted with nanos precision. - */ + @Override public boolean isLocalTimeWithNanos() { return localTimeWithNanos; } - /** - * Set to true if LocalTime should be persisted with nanos precision. - *

- * Otherwise it is persisted using java.sql.Time which is seconds precision. - */ + @Override public void setLocalTimeWithNanos(boolean localTimeWithNanos) { this.localTimeWithNanos = localTimeWithNanos; } - /** - * Return true if Duration should be persisted with nanos precision (SQL DECIMAL). - *

- * Otherwise it is persisted with second precision (SQL INTEGER). - */ + @Override public boolean isDurationWithNanos() { return durationWithNanos; } - /** - * Set to true if Duration should be persisted with nanos precision (SQL DECIMAL). - *

- * Otherwise it is persisted with second precision (SQL INTEGER). - */ + @Override public void setDurationWithNanos(boolean durationWithNanos) { this.durationWithNanos = durationWithNanos; } - /** - * Set to true to run DB migrations on server start. - *

- * 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. - */ + @Override public void setRunMigration(boolean runMigration) { this.runMigration = runMigration; } - /** - * Return true if the DB migration should run on server start. - */ + @Override public boolean isRunMigration() { final String run = System.getProperty("ebean.migration.run"); return (run != null) ? Boolean.parseBoolean(run) : runMigration; } - /** - * Set to true to generate the "create all" DDL on startup. - *

- * 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. - */ + @Override public void setDdlGenerate(boolean ddlGenerate) { this.ddlGenerate = ddlGenerate; } - /** - * Set to true to run the generated "create all DDL" on startup. - *

- * 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. - */ + @Override public void setDdlRun(boolean ddlRun) { this.ddlRun = 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. - */ + @Override public void setDdlExtra(boolean ddlExtra) { this.ddlExtra = ddlExtra; } - /** - * Return true if the "drop all ddl" should be skipped. - *

- * 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. - */ + @Override public boolean isDdlCreateOnly() { return ddlCreateOnly; } - /** - * Set to true if the "drop all ddl" should be skipped. - *

- * 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. - */ + @Override public void setDdlCreateOnly(boolean ddlCreateOnly) { this.ddlCreateOnly = ddlCreateOnly; } - /** - * Return SQL script to execute after the "create all" DDL has been run. - *

- * 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. - */ + @Override public String getDdlSeedSql() { return ddlSeedSql; } - /** - * Set a SQL script to execute after the "create all" DDL has been run. - *

- * 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. - */ + @Override public void setDdlSeedSql(String ddlSeedSql) { this.ddlSeedSql = ddlSeedSql; } - /** - * Return a SQL script to execute before the "create all" DDL has been run. - */ + @Override public String getDdlInitSql() { return ddlInitSql; } - /** - * Set a SQL script to execute before the "create all" DDL has been run. - */ + @Override public void setDdlInitSql(String ddlInitSql) { this.ddlInitSql = ddlInitSql; } - /** - * Return true if the DDL should be generated. - */ + @Override public boolean isDdlGenerate() { return ddlGenerate; } - /** - * Return true if the DDL should be run. - */ + @Override public boolean isDdlRun() { return ddlRun; } - /** - * Return true, if extra-ddl.xml should be executed. - */ + @Override public boolean isDdlExtra() { return ddlExtra; } - /** - * Set the header to use with DDL generation. - */ + @Override public void setDdlHeader(String ddlHeader) { this.ddlHeader = ddlHeader; } - /** - * Return the header to use with DDL generation. - */ + @Override public String getDdlHeader() { if (ddlHeader != null && !ddlHeader.isEmpty()) { String header = ddlHeader.replace("${version}", EbeanVersion.getVersion()); @@ -2226,540 +1566,291 @@ public class DatabaseConfig { return ddlHeader; } - /** - * Return true if strict mode is used which includes a check that non-null columns have a default value. - */ + @Override public boolean isDdlStrictMode() { return ddlStrictMode; } - /** - * Set to false to turn off strict mode allowing non-null columns to not have a default value. - */ + @Override public void setDdlStrictMode(boolean ddlStrictMode) { this.ddlStrictMode = ddlStrictMode; } - /** - * Return a comma and equals delimited placeholders that are substituted in DDL scripts. - */ + @Override public String getDdlPlaceholders() { return ddlPlaceholders; } - /** - * Set a comma and equals delimited placeholders that are substituted in DDL scripts. - */ + @Override public void setDdlPlaceholders(String ddlPlaceholders) { this.ddlPlaceholders = ddlPlaceholders; } - /** - * Return a map of placeholder values that are substituted in DDL scripts. - */ + @Override public Map getDdlPlaceholderMap() { return ddlPlaceholderMap; } - /** - * Set a map of placeholder values that are substituted in DDL scripts. - */ + @Override public void setDdlPlaceholderMap(Map ddlPlaceholderMap) { this.ddlPlaceholderMap = ddlPlaceholderMap; } - /** - * Return true if the class path search should be disabled. - */ + @Override public boolean isDisableClasspathSearch() { return disableClasspathSearch; } - /** - * 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. - */ + @Override public void setDisableClasspathSearch(boolean disableClasspathSearch) { this.disableClasspathSearch = disableClasspathSearch; } - /** - * Return the mode to use for Joda LocalTime support 'normal' or 'utc'. - */ + @Override public String getJodaLocalTimeMode() { return jodaLocalTimeMode; } - /** - * Set the mode to use for Joda LocalTime support 'normal' or 'utc'. - */ + @Override public void setJodaLocalTimeMode(String jodaLocalTimeMode) { this.jodaLocalTimeMode = jodaLocalTimeMode; } - /** - * Programmatically add classes (typically entities) that this server should use. - *

- * The class can be an Entity, Embedded type, ScalarType, BeanPersistListener, - * BeanFinder or BeanPersistController. - *

- * If no classes are specified then the classes are found automatically via - * searching the class path. - * - * @param cls the entity type (or other type) that should be registered by this database. - */ + @Override public void addClass(Class cls) { classes.add(cls); } - /** - * Register all the classes (typically entity classes). - */ + @Override public void addAll(Collection> classList) { if (classList != null && !classList.isEmpty()) { classes.addAll(classList); } } - /** - * Add a package to search for entities via class path search. - *

- * This is only used if classes have not been explicitly specified. - */ + @Override public void addPackage(String packageName) { packages.add(packageName); } - /** - * Return packages to search for entities via class path search. - *

- * This is only used if classes have not been explicitly specified. - */ + @Override public List getPackages() { return packages; } - /** - * Set packages to search for entities via class path search. - *

- * This is only used if classes have not been explicitly specified. - */ + @Override public void setPackages(List packages) { this.packages = packages; } - /** - * Set the list of classes (entities, listeners, scalarTypes etc) that should - * be used for this database. - *

- * If no classes are specified then the classes are found automatically via - * searching the class path. - *

- * Alternatively the classes can contain added via {@link #addClass(Class)}. - */ + @Override public void setClasses(Collection> classes) { this.classes = new HashSet<>(classes); } - /** - * Return the classes registered for this database. Typically, this includes - * entities and perhaps listeners. - */ + @Override public Set> classes() { return classes; } /** * @deprecated - migrate to {@link #classes()}. - *

- * Sorry if returning Set rather than List breaks code but it feels safer to - * do that than a subtle change to return a shallow copy which you will not detect. */ + @Override + @SuppressWarnings("removal") @Deprecated(forRemoval = true) public Set> getClasses() { return classes; } - /** - * Return true if L2 bean cache should be skipped once writes have occurred on a transaction. - *

- * This defaults to true and means that for "find by id" and "find by natural key" - * queries that normally hit L2 bean cache automatically will not do so after a write/persist - * on the transaction. - *

- *

{@code
-   *
-   *   // assume Customer has L2 bean caching enabled ...
-   *
-   *   try (Transaction transaction = DB.beginTransaction()) {
-   *
-   *     // this uses L2 bean cache as the transaction
-   *     // ... is considered "query only" at this point
-   *     Customer.find.byId(42);
-   *
-   *     // transaction no longer "query only" once
-   *     // ... a bean has been saved etc
-   *     DB.save(someBean);
-   *
-   *     // will NOT use L2 bean cache as the transaction
-   *     // ... is no longer considered "query only"
-   *     Customer.find.byId(55);
-   *
-   *
-   *
-   *     // explicit control - please use L2 bean cache
-   *
-   *     transaction.setSkipCache(false);
-   *     Customer.find.byId(77); // hit the l2 bean cache
-   *
-   *
-   *     // explicit control - please don't use L2 bean cache
-   *
-   *     transaction.setSkipCache(true);
-   *     Customer.find.byId(99); // skips l2 bean cache
-   *
-   *   }
-   *
-   * }
- * - * @see Transaction#setSkipCache(boolean) - */ + @Override public boolean isSkipCacheAfterWrite() { return skipCacheAfterWrite; } - /** - * Set to false when we still want to hit the cache after a write has occurred on a transaction. - */ + @Override public void setSkipCacheAfterWrite(boolean skipCacheAfterWrite) { this.skipCacheAfterWrite = skipCacheAfterWrite; } - /** - * Returns true if updates in JDBC batch default to include all properties by default. - */ + @Override public boolean isUpdateAllPropertiesInBatch() { return updateAllPropertiesInBatch; } - /** - * Set to false if by default updates in JDBC batch should not include all properties. - *

- * This mode can be explicitly set per transaction. - * - * @see Transaction#setUpdateAllLoadedProperties(boolean) - */ + @Override public void setUpdateAllPropertiesInBatch(boolean updateAllPropertiesInBatch) { this.updateAllPropertiesInBatch = updateAllPropertiesInBatch; } - /** - * Returns the resource directory. - */ + @Override public String getResourceDirectory() { return resourceDirectory; } - /** - * Sets the resource directory. - */ + @Override public void setResourceDirectory(String resourceDirectory) { this.resourceDirectory = resourceDirectory; } - /** - * Add a custom type mapping. - *

- *

{@code
-   *
-   *   // set the default mapping for BigDecimal.class/decimal
-   *   config.addCustomMapping(DbType.DECIMAL, "decimal(18,6)");
-   *
-   *   // set the default mapping for String.class/varchar but only for Postgres
-   *   config.addCustomMapping(DbType.VARCHAR, "text", Platform.POSTGRES);
-   *
-   * }
- * - * @param type The DB type this mapping should apply to - * @param columnDefinition The column definition that should be used - * @param platform Optionally specify the platform this mapping should apply to. - */ + @Override public void addCustomMapping(DbType type, String columnDefinition, Platform platform) { platformConfig.addCustomMapping(type, columnDefinition, platform); } - /** - * Add a custom type mapping that applies to all platforms. - *

- *

{@code
-   *
-   *   // set the default mapping for BigDecimal/decimal
-   *   config.addCustomMapping(DbType.DECIMAL, "decimal(18,6)");
-   *
-   *   // set the default mapping for String/varchar
-   *   config.addCustomMapping(DbType.VARCHAR, "text");
-   *
-   * }
- * - * @param type The DB type this mapping should apply to - * @param columnDefinition The column definition that should be used - */ + @Override public void addCustomMapping(DbType type, String columnDefinition) { platformConfig.addCustomMapping(type, columnDefinition); } - /** - * Register a BeanQueryAdapter instance. - *

- * Note alternatively you can use {@link #setQueryAdapters(List)} to set all - * the BeanQueryAdapter instances. - */ + @Override public void add(BeanQueryAdapter beanQueryAdapter) { queryAdapters.add(beanQueryAdapter); } - /** - * Return the BeanQueryAdapter instances. - */ + @Override public List getQueryAdapters() { return queryAdapters; } - /** - * Register all the BeanQueryAdapter instances. - *

- * Note alternatively you can use {@link #add(BeanQueryAdapter)} to add - * BeanQueryAdapter instances one at a time. - */ + @Override public void setQueryAdapters(List queryAdapters) { this.queryAdapters = queryAdapters; } - /** - * Return the custom IdGenerator instances. - */ + @Override public List getIdGenerators() { return idGenerators; } - /** - * Set the custom IdGenerator instances. - */ + @Override public void setIdGenerators(List idGenerators) { this.idGenerators = idGenerators; } - /** - * Register a customer IdGenerator instance. - */ + @Override public void add(IdGenerator idGenerator) { idGenerators.add(idGenerator); } - /** - * Register a BeanPersistController instance. - *

- * Note alternatively you can use {@link #setPersistControllers(List)} to set - * all the BeanPersistController instances. - */ + @Override public void add(BeanPersistController beanPersistController) { persistControllers.add(beanPersistController); } - /** - * Register a BeanPostLoad instance. - *

- * Note alternatively you can use {@link #setPostLoaders(List)} to set - * all the BeanPostLoad instances. - */ + @Override public void add(BeanPostLoad postLoad) { postLoaders.add(postLoad); } - /** - * Register a BeanPostConstructListener instance. - *

- * Note alternatively you can use {@link #setPostConstructListeners(List)} to set - * all the BeanPostConstructListener instances. - */ + @Override public void add(BeanPostConstructListener listener) { postConstructListeners.add(listener); } - /** - * Return the list of BeanFindController instances. - */ + @Override public List getFindControllers() { return findControllers; } - /** - * Set the list of BeanFindController instances. - */ + @Override public void setFindControllers(List findControllers) { this.findControllers = findControllers; } - /** - * Return the list of BeanPostLoader instances. - */ + @Override public List getPostLoaders() { return postLoaders; } - /** - * Set the list of BeanPostLoader instances. - */ + @Override public void setPostLoaders(List postLoaders) { this.postLoaders = postLoaders; } - /** - * Return the list of BeanPostLoader instances. - */ + @Override public List getPostConstructListeners() { return postConstructListeners; } - /** - * Set the list of BeanPostLoader instances. - */ + @Override public void setPostConstructListeners(List listeners) { this.postConstructListeners = listeners; } - /** - * Return the BeanPersistController instances. - */ + @Override public List getPersistControllers() { return persistControllers; } - /** - * Register all the BeanPersistController instances. - *

- * Note alternatively you can use {@link #add(BeanPersistController)} to add - * BeanPersistController instances one at a time. - */ + @Override public void setPersistControllers(List persistControllers) { this.persistControllers = persistControllers; } - /** - * Register a BeanPersistListener instance. - *

- * Note alternatively you can use {@link #setPersistListeners(List)} to set - * all the BeanPersistListener instances. - */ + @Override public void add(BeanPersistListener beanPersistListener) { persistListeners.add(beanPersistListener); } - /** - * Return the BeanPersistListener instances. - */ + @Override public List getPersistListeners() { return persistListeners; } - /** - * Add a BulkTableEventListener - */ + @Override public void add(BulkTableEventListener bulkTableEventListener) { bulkTableEventListeners.add(bulkTableEventListener); } - /** - * Return the list of BulkTableEventListener instances. - */ + @Override public List getBulkTableEventListeners() { return bulkTableEventListeners; } - /** - * Add a ServerConfigStartup. - */ + @Override public void addServerConfigStartup(ServerConfigStartup configStartupListener) { configStartupListeners.add(configStartupListener); } - /** - * Return the list of ServerConfigStartup instances. - */ + @Override public List getServerConfigStartupListeners() { return configStartupListeners; } - /** - * Register all the BeanPersistListener instances. - *

- * Note alternatively you can use {@link #add(BeanPersistListener)} to add - * BeanPersistListener instances one at a time. - */ + @Override public void setPersistListeners(List persistListeners) { this.persistListeners = persistListeners; } - /** - * Return the default PersistenceContextScope to be used if one is not explicitly set on a query. - *

- * The PersistenceContextScope can specified on each query via {@link io.ebean - * .Query#setPersistenceContextScope(io.ebean.PersistenceContextScope)}. If it - * is not set on the query this default scope is used. - * - * @see Query#setPersistenceContextScope(PersistenceContextScope) - */ + @Override public PersistenceContextScope getPersistenceContextScope() { // if somehow null return TRANSACTION scope return persistenceContextScope == null ? PersistenceContextScope.TRANSACTION : persistenceContextScope; } - /** - * Set the PersistenceContext scope to be used if one is not explicitly set on a query. - *

- * This defaults to {@link PersistenceContextScope#TRANSACTION}. - *

- * The PersistenceContextScope can specified on each query via {@link io.ebean - * .Query#setPersistenceContextScope(io.ebean.PersistenceContextScope)}. If it - * is not set on the query this scope is used. - * - * @see Query#setPersistenceContextScope(PersistenceContextScope) - */ + @Override public void setPersistenceContextScope(PersistenceContextScope persistenceContextScope) { this.persistenceContextScope = persistenceContextScope; } - /** - * Return the ClassLoadConfig which is used to detect Joda, Java8 types etc and also - * create new instances of plugins given a className. - */ + @Override public ClassLoadConfig getClassLoadConfig() { return classLoadConfig; } - /** - * Set the ClassLoadConfig which is used to detect Joda, Java8 types etc and also - * create new instances of plugins given a className. - */ + @Override public void setClassLoadConfig(ClassLoadConfig classLoadConfig) { this.classLoadConfig = classLoadConfig; } - /** - * Load settings from application.properties, application.yaml and other sources. - *

- * Uses avaje-config to load configuration properties. Goto https://avaje.io/config - * for detail on how and where properties are loaded from. - */ + @Override public void loadFromProperties() { this.properties = Config.asProperties(); configureFromProperties(); } - /** - * Load the settings from the given properties - */ + @Override public void loadFromProperties(Properties properties) { // keep the properties used for configuration so that these are available for plugins this.properties = Config.asConfiguration().eval(properties); @@ -2790,9 +1881,7 @@ public class DatabaseConfig { return list; } - /** - * Return the properties that we used for configuration and were set via a call to loadFromProperties(). - */ + @Override public Properties getProperties() { return properties; } @@ -3014,10 +2103,7 @@ public class DatabaseConfig { } } - /** - * Return the PersistBatch mode to use for 'batchOnCascade' taking into account if the database - * platform supports getGeneratedKeys in batch mode. - */ + @Override public PersistBatch appliedPersistBatchOnCascade() { if (persistBatchOnCascade == PersistBatch.INHERIT) { // use the platform default (ALL except SQL Server which has NONE) @@ -3026,164 +2112,97 @@ public class DatabaseConfig { return persistBatchOnCascade; } - /** - * Return the Jackson ObjectMapper. - *

- * Note that this is not strongly typed as Jackson ObjectMapper is an optional dependency. - */ + @Override public Object getObjectMapper() { return objectMapper; } - /** - * Set the Jackson ObjectMapper. - *

- * Note that this is not strongly typed as Jackson ObjectMapper is an optional dependency. - */ + @Override public void setObjectMapper(Object objectMapper) { this.objectMapper = objectMapper; } - /** - * Return true if eq("someProperty", null) should to generate "1=1" rather than "is null" sql expression. - */ + @Override public boolean isExpressionEqualsWithNullAsNoop() { return expressionEqualsWithNullAsNoop; } - /** - * Set to true if you want eq("someProperty", null) to generate "1=1" rather than "is null" sql expression. - *

- * Setting this to true has the effect that eq(propertyName, value), ieq(propertyName, value) and - * 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". - */ + @Override public void setExpressionEqualsWithNullAsNoop(boolean expressionEqualsWithNullAsNoop) { this.expressionEqualsWithNullAsNoop = expressionEqualsWithNullAsNoop; } - /** - * Return true if native ILIKE expression should be used if supported by the database platform (e.g. Postgres). - */ + @Override public boolean isExpressionNativeIlike() { return expressionNativeIlike; } - /** - * Set to true to use native ILIKE expression if supported by the database platform (e.g. Postgres). - */ + @Override public void setExpressionNativeIlike(boolean expressionNativeIlike) { this.expressionNativeIlike = expressionNativeIlike; } - /** - * Return the enabled L2 cache regions. - */ + @Override public String getEnabledL2Regions() { return enabledL2Regions; } - /** - * Set the enabled L2 cache regions (comma delimited). - */ + @Override public void setEnabledL2Regions(String enabledL2Regions) { this.enabledL2Regions = enabledL2Regions; } - /** - * Return true if L2 cache is disabled. - */ + @Override public boolean isDisableL2Cache() { return disableL2Cache; } - /** - * Set to true to disable L2 caching. Typically useful in performance testing. - */ + @Override public void setDisableL2Cache(boolean disableL2Cache) { this.disableL2Cache = disableL2Cache; } - /** - * Return true to use local only L2 cache. Effectively ignore l2 cache plugin like ebean-redis etc. - */ + @Override public boolean isLocalOnlyL2Cache() { return localOnlyL2Cache; } - /** - * Force the use of local only L2 cache. Effectively ignore l2 cache plugin like ebean-redis etc. - */ + @Override public void setLocalOnlyL2Cache(boolean localOnlyL2Cache) { this.localOnlyL2Cache = localOnlyL2Cache; } - /** - * Returns if we use javax.validation.constraints.NotNull - */ + @Override public boolean isUseValidationNotNull() { return useValidationNotNull; } - /** - * Controls if Ebean should ignore &x64;javax.validation.contstraints.NotNull or - * &x64;jakarta.validation.contstraints.NotNull - * with respect to generating a NOT NULL column. - *

- * Normally when Ebean sees javax NotNull annotation it means that column is defined as NOT NULL. - * 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. - */ + @Override public void setUseValidationNotNull(boolean useValidationNotNull) { this.useValidationNotNull = useValidationNotNull; } - /** - * Return true if L2 cache notification should run in the foreground. - */ + @Override public boolean isNotifyL2CacheInForeground() { return notifyL2CacheInForeground; } - /** - * Set this to true to run L2 cache notification in the foreground. - *

- * In general we don't want to do that as when we use a distributed cache (like Ignite, Hazelcast etc) - * we are making network calls and we prefer to do this in background and not impact the response time - * of the executing transaction. - */ + @Override public void setNotifyL2CacheInForeground(boolean notifyL2CacheInForeground) { this.notifyL2CacheInForeground = notifyL2CacheInForeground; } - /** - * Return the time to live for ebean's internal query plan. - */ + @Override public int getQueryPlanTTLSeconds() { return queryPlanTTLSeconds; } - /** - * Set the time to live for ebean's internal query plan. - *

- * 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. - */ + @Override public void setQueryPlanTTLSeconds(int queryPlanTTLSeconds) { this.queryPlanTTLSeconds = queryPlanTTLSeconds; } - /** - * Create a new PlatformConfig based of the one held but with overridden properties by reading - * properties with the given path and prefix. - *

- * Typically used in Db Migration generation for many platform targets that might have different - * configuration for IdType, UUID, quoted identifiers etc. - * - * @param propertiesPath The properties path used for loading and setting properties - * @param platformPrefix The prefix used for loading and setting properties - * @return A copy of the PlatformConfig with overridden properties - */ + @Override public PlatformConfig newPlatformConfig(String propertiesPath, String platformPrefix) { if (properties == null) { properties = new Properties(); @@ -3194,9 +2213,7 @@ public class DatabaseConfig { return config; } - /** - * Add a mapping location to search for xml mapping via class path search. - */ + @Override public void addMappingLocation(String mappingLocation) { if (mappingLocations == null) { mappingLocations = new ArrayList<>(); @@ -3204,184 +2221,117 @@ public class DatabaseConfig { mappingLocations.add(mappingLocation); } - /** - * Return mapping locations to search for xml mapping via class path search. - */ + @Override public List getMappingLocations() { return mappingLocations; } - /** - * Set mapping locations to search for xml mapping via class path search. - *

- * This is only used if classes have not been explicitly specified. - */ + @Override public void setMappingLocations(List mappingLocations) { this.mappingLocations = mappingLocations; } - /** - * When false we need explicit @GeneratedValue mapping to assign - * Identity or Sequence generated values. When true Id properties are automatically - * assigned Identity or Sequence without the GeneratedValue mapping. - */ + @Override public boolean isIdGeneratorAutomatic() { return idGeneratorAutomatic; } - /** - * Set to false such that Id properties require explicit @GeneratedValue - * mapping before they are assigned Identity or Sequence generation based on platform. - */ + @Override public void setIdGeneratorAutomatic(boolean idGeneratorAutomatic) { this.idGeneratorAutomatic = idGeneratorAutomatic; } - /** - * Return true if query plan capture is enabled. - */ + @Override public boolean isQueryPlanEnable() { return queryPlanEnable; } - /** - * Set to true to enable query plan capture. - */ + @Override public void setQueryPlanEnable(boolean queryPlanEnable) { this.queryPlanEnable = queryPlanEnable; } - /** - * Return the query plan collection threshold in microseconds. - */ + @Override public long getQueryPlanThresholdMicros() { return queryPlanThresholdMicros; } - /** - * Set the query plan collection threshold in microseconds. - *

- * Queries executing slower than this will have bind values captured such that later - * the query plan can be captured and reported. - */ + @Override public void setQueryPlanThresholdMicros(long queryPlanThresholdMicros) { this.queryPlanThresholdMicros = queryPlanThresholdMicros; } - /** - * Return true if periodic capture of query plans is enabled. - */ + @Override public boolean isQueryPlanCapture() { return queryPlanCapture; } - /** - * Set to true to turn on periodic capture of query plans. - */ + @Override public void setQueryPlanCapture(boolean queryPlanCapture) { this.queryPlanCapture = queryPlanCapture; } - /** - * Return the frequency to capture query plans. - */ + @Override public long getQueryPlanCapturePeriodSecs() { return queryPlanCapturePeriodSecs; } - /** - * Set the frequency in seconds to capture query plans. - */ + @Override public void setQueryPlanCapturePeriodSecs(long queryPlanCapturePeriodSecs) { this.queryPlanCapturePeriodSecs = queryPlanCapturePeriodSecs; } - /** - * Return the time after which a capture query plans request will - * stop capturing more query plans. - *

- * Effectively this controls the amount of load/time we want to - * allow for query plan capture. - */ + @Override public long getQueryPlanCaptureMaxTimeMillis() { return queryPlanCaptureMaxTimeMillis; } - /** - * Set the time after which a capture query plans request will - * stop capturing more query plans. - *

- * Effectively this controls the amount of load/time we want to - * allow for query plan capture. - */ + @Override public void setQueryPlanCaptureMaxTimeMillis(long queryPlanCaptureMaxTimeMillis) { this.queryPlanCaptureMaxTimeMillis = queryPlanCaptureMaxTimeMillis; } - /** - * Return the max number of query plans captured per request. - */ + @Override public int getQueryPlanCaptureMaxCount() { return queryPlanCaptureMaxCount; } - /** - * Set the max number of query plans captured per request. - */ + @Override public void setQueryPlanCaptureMaxCount(int queryPlanCaptureMaxCount) { this.queryPlanCaptureMaxCount = queryPlanCaptureMaxCount; } - /** - * Return the listener used to process captured query plans. - */ + @Override public QueryPlanListener getQueryPlanListener() { return queryPlanListener; } - /** - * Set the listener used to process captured query plans. - */ + @Override public void setQueryPlanListener(QueryPlanListener queryPlanListener) { this.queryPlanListener = queryPlanListener; } - /** - * Return true if metrics should be dumped when the server is shutdown. - */ + @Override public boolean isDumpMetricsOnShutdown() { return dumpMetricsOnShutdown; } - /** - * Set to true if metrics should be dumped when the server is shutdown. - */ + @Override public void setDumpMetricsOnShutdown(boolean dumpMetricsOnShutdown) { this.dumpMetricsOnShutdown = dumpMetricsOnShutdown; } - /** - * Return the options for dumping metrics. - */ + @Override public String getDumpMetricsOptions() { return dumpMetricsOptions; } - /** - * Include 'sql' or 'hash' in options such that they are included in the output. - * - * @param dumpMetricsOptions Example "sql,hash", "sql" - */ + @Override public void setDumpMetricsOptions(String dumpMetricsOptions) { this.dumpMetricsOptions = dumpMetricsOptions; } - /** - * Return true if entity classes should be loaded and registered via EntityClassRegister. - *

- * When false we either register entity classes via application code or use classpath - * scanning to find and register entity classes. - */ + @Override public boolean isLoadModuleInfo() { return loadModuleInfo; } @@ -3389,32 +2339,24 @@ public class DatabaseConfig { /** * @deprecated - migrate to {@link #isLoadModuleInfo()}. */ + @Override + @SuppressWarnings("removal") @Deprecated(forRemoval = true) public boolean isAutoLoadModuleInfo() { return loadModuleInfo; } - /** - * 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). - * This is on by default and setting this to false turns it off. - */ + @Override public void setLoadModuleInfo(boolean loadModuleInfo) { this.loadModuleInfo = loadModuleInfo; } - /** - * Return the naming convention to apply to metrics names. - */ + @Override public Function getMetricNaming() { return metricNaming; } - /** - * Set the naming convention to apply to metrics names. - */ + @Override public void setMetricNaming(Function metricNaming) { this.metricNaming = metricNaming; } diff --git a/ebean-api/src/main/java/io/ebean/config/DatabaseConfigProvider.java b/ebean-api/src/main/java/io/ebean/config/DatabaseConfigProvider.java index 066af5fc4..68b8d9167 100644 --- a/ebean-api/src/main/java/io/ebean/config/DatabaseConfigProvider.java +++ b/ebean-api/src/main/java/io/ebean/config/DatabaseConfigProvider.java @@ -1,5 +1,7 @@ package io.ebean.config; +import io.ebean.DatabaseBuilder; + /** * Provides a ServiceLoader based mechanism to configure a DatabaseConfig. *

@@ -35,5 +37,5 @@ public interface DatabaseConfigProvider { * Typically we explicitly register entity bean classes and thus avoid classpath scanning. *

*/ - void apply(DatabaseConfig config); + void apply(DatabaseBuilder config); } diff --git a/ebean-api/src/main/java/io/ebean/event/ServerConfigStartup.java b/ebean-api/src/main/java/io/ebean/event/ServerConfigStartup.java index f29b8a22a..ab7cc2dc6 100644 --- a/ebean-api/src/main/java/io/ebean/event/ServerConfigStartup.java +++ b/ebean-api/src/main/java/io/ebean/event/ServerConfigStartup.java @@ -1,6 +1,6 @@ package io.ebean.event; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; /** * Used to configure the server on startup. @@ -13,6 +13,6 @@ public interface ServerConfigStartup { /** * On starting configure the DatabaseConfig. */ - void onStart(DatabaseConfig config); + void onStart(DatabaseBuilder config); } diff --git a/ebean-api/src/main/java/io/ebean/plugin/SpiServer.java b/ebean-api/src/main/java/io/ebean/plugin/SpiServer.java index f12869b7a..9f558571a 100644 --- a/ebean-api/src/main/java/io/ebean/plugin/SpiServer.java +++ b/ebean-api/src/main/java/io/ebean/plugin/SpiServer.java @@ -3,7 +3,7 @@ package io.ebean.plugin; import io.ebean.Database; import io.ebean.bean.BeanLoader; import io.ebean.bean.EntityBeanIntercept; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; import io.ebean.config.dbplatform.DatabasePlatform; import java.util.List; @@ -16,7 +16,7 @@ public interface SpiServer extends Database { /** * Return the DatabaseConfig. */ - DatabaseConfig config(); + DatabaseBuilder config(); /** * Return the DatabasePlatform for this database. diff --git a/ebean-api/src/main/java/io/ebean/service/SpiContainer.java b/ebean-api/src/main/java/io/ebean/service/SpiContainer.java index 547f4648e..9b685c9ce 100644 --- a/ebean-api/src/main/java/io/ebean/service/SpiContainer.java +++ b/ebean-api/src/main/java/io/ebean/service/SpiContainer.java @@ -1,7 +1,7 @@ package io.ebean.service; import io.ebean.Database; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; /** * Creates the Database implementations. This is used internally by the EbeanServerFactory and is not currently @@ -14,7 +14,7 @@ public interface SpiContainer { * * @param configuration The configuration information for this database. */ - Database createServer(DatabaseConfig configuration); + Database createServer(DatabaseBuilder configuration); /** * Create an EbeanServer just using the name. diff --git a/ebean-api/src/test/java/io/ebean/config/DatabaseConfigTest.java b/ebean-api/src/test/java/io/ebean/config/DatabaseConfigTest.java index a449d9dfe..9e19c484a 100644 --- a/ebean-api/src/test/java/io/ebean/config/DatabaseConfigTest.java +++ b/ebean-api/src/test/java/io/ebean/config/DatabaseConfigTest.java @@ -1,6 +1,7 @@ package io.ebean.config; import com.fasterxml.jackson.databind.ObjectMapper; +import io.ebean.DatabaseBuilder; import io.ebean.annotation.MutationDetection; import io.ebean.annotation.PersistBatch; import io.ebean.config.dbplatform.IdType; @@ -17,7 +18,7 @@ class DatabaseConfigTest { @Test void testLoadFromEbeanProperties() { - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); config.loadFromProperties(); assertEquals(PersistBatch.NONE, config.getPersistBatch()); @@ -32,7 +33,7 @@ class DatabaseConfigTest { Properties props = new Properties(); props.setProperty("ddl.initSql", "${user.home}" + fileSeparator + "initSql"); - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); config.loadFromProperties(props); String ddlInitSql = config.getDdlInitSql(); @@ -41,7 +42,7 @@ class DatabaseConfigTest { @Test void testLoadWithProperties() { - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); config.setPersistBatch(PersistBatch.NONE); config.setPersistBatchOnCascade(PersistBatch.NONE); config.setAutoReadOnlyDataSource(false); @@ -149,7 +150,7 @@ class DatabaseConfigTest { @Test void test_defaults() { - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); assertTrue(config.isIdGeneratorAutomatic()); assertTrue(config.isDefaultServer()); assertFalse(config.isAutoPersistUpdates()); @@ -184,7 +185,7 @@ class DatabaseConfigTest { void test_putServiceObject() { ObjectMapper objectMapper = new ObjectMapper(); - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); config.putServiceObject(objectMapper); ObjectMapper mapper0 = config.getServiceObject(ObjectMapper.class); diff --git a/ebean-bom/pom.xml b/ebean-bom/pom.xml index 5af0768f8..54e4b0a8e 100644 --- a/ebean-bom/pom.xml +++ b/ebean-bom/pom.xml @@ -113,13 +113,13 @@ io.ebean ebean-joda-time - 13.18.0 + 13.24.0-RC1 io.ebean ebean-jackson-jsonnode - 13.18.0 + 13.24.0-RC1 diff --git a/ebean-core-type/src/main/java/io/ebean/core/type/ExtraTypeFactory.java b/ebean-core-type/src/main/java/io/ebean/core/type/ExtraTypeFactory.java index 4901ca456..e4da6fd7b 100644 --- a/ebean-core-type/src/main/java/io/ebean/core/type/ExtraTypeFactory.java +++ b/ebean-core-type/src/main/java/io/ebean/core/type/ExtraTypeFactory.java @@ -1,6 +1,6 @@ package io.ebean.core.type; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; import java.util.List; @@ -12,5 +12,5 @@ public interface ExtraTypeFactory { /** * Provide extra types to Ebean. */ - List> createTypes(DatabaseConfig config, Object objectMapper); + List> createTypes(DatabaseBuilder config, Object objectMapper); } diff --git a/ebean-core-type/src/main/java/io/ebean/core/type/ScalarTypeSetFactory.java b/ebean-core-type/src/main/java/io/ebean/core/type/ScalarTypeSetFactory.java index 21d133a37..89a6187d1 100644 --- a/ebean-core-type/src/main/java/io/ebean/core/type/ScalarTypeSetFactory.java +++ b/ebean-core-type/src/main/java/io/ebean/core/type/ScalarTypeSetFactory.java @@ -1,7 +1,7 @@ package io.ebean.core.type; import io.avaje.lang.Nullable; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; /** * Factory to create ScalarTypeSet. @@ -12,6 +12,6 @@ public interface ScalarTypeSetFactory { * Create the ScalarTypeSet given the config and optional objectMapper. */ @Nullable - ScalarTypeSet createTypeSet(DatabaseConfig config, @Nullable Object objectMapper); + ScalarTypeSet createTypeSet(DatabaseBuilder config, @Nullable Object objectMapper); } diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/GeoTypeProvider.java b/ebean-core/src/main/java/io/ebeaninternal/api/GeoTypeProvider.java index 59fb4bb90..e9dcd6ebe 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/api/GeoTypeProvider.java +++ b/ebean-core/src/main/java/io/ebeaninternal/api/GeoTypeProvider.java @@ -1,6 +1,6 @@ package io.ebeaninternal.api; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; import io.ebeaninternal.server.type.GeoTypeBinder; /** @@ -11,5 +11,5 @@ public interface GeoTypeProvider { /** * Create a binder for binding geometry types. */ - GeoTypeBinder createBinder(DatabaseConfig config); + GeoTypeBinder createBinder(DatabaseBuilder config); } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/autotune/AutoTuneServiceProvider.java b/ebean-core/src/main/java/io/ebeaninternal/server/autotune/AutoTuneServiceProvider.java index c63900b03..f2bc49363 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/autotune/AutoTuneServiceProvider.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/autotune/AutoTuneServiceProvider.java @@ -1,9 +1,9 @@ package io.ebeaninternal.server.autotune; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; import io.ebeaninternal.api.SpiEbeanServer; public interface AutoTuneServiceProvider { - AutoTuneService create(SpiEbeanServer server, DatabaseConfig config); + AutoTuneService create(SpiEbeanServer server, DatabaseBuilder config); } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/cache/CacheManagerOptions.java b/ebean-core/src/main/java/io/ebeaninternal/server/cache/CacheManagerOptions.java index ae0c10f4c..e3af6137c 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/cache/CacheManagerOptions.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/cache/CacheManagerOptions.java @@ -4,7 +4,7 @@ import io.ebean.cache.QueryCacheEntryValidate; import io.ebean.cache.ServerCacheFactory; import io.ebean.cache.ServerCacheOptions; import io.ebean.config.CurrentTenantProvider; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; import io.ebeaninternal.server.cluster.ClusterManager; /** @@ -13,7 +13,7 @@ import io.ebeaninternal.server.cluster.ClusterManager; public final class CacheManagerOptions { private final ClusterManager clusterManager; - private final DatabaseConfig databaseConfig; + private final DatabaseBuilder databaseBuilder; private final boolean localL2Caching; private CurrentTenantProvider currentTenantProvider; private QueryCacheEntryValidate queryCacheEntryValidate; @@ -24,15 +24,15 @@ public final class CacheManagerOptions { CacheManagerOptions() { this.localL2Caching = true; this.clusterManager = null; - this.databaseConfig = null; + this.databaseBuilder = null; this.cacheFactory = new DefaultServerCacheFactory(); this.beanDefault = new ServerCacheOptions(); this.queryDefault = new ServerCacheOptions(); } - public CacheManagerOptions(ClusterManager clusterManager, DatabaseConfig config, boolean localL2Caching) { + public CacheManagerOptions(ClusterManager clusterManager, DatabaseBuilder config, boolean localL2Caching) { this.clusterManager = clusterManager; - this.databaseConfig = config; + this.databaseBuilder = config; this.localL2Caching = localL2Caching; this.currentTenantProvider = config.getCurrentTenantProvider(); } @@ -55,7 +55,7 @@ public final class CacheManagerOptions { } public String getServerName() { - return (databaseConfig == null) ? "db" : databaseConfig.getName(); + return (databaseBuilder == null) ? "db" : databaseBuilder.getName(); } public boolean isLocalL2Caching() { diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/cache/DefaultServerCachePlugin.java b/ebean-core/src/main/java/io/ebeaninternal/server/cache/DefaultServerCachePlugin.java index d4a6a247f..dac4c0627 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/cache/DefaultServerCachePlugin.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/cache/DefaultServerCachePlugin.java @@ -3,7 +3,7 @@ package io.ebeaninternal.server.cache; import io.ebean.BackgroundExecutor; import io.ebean.cache.ServerCacheFactory; import io.ebean.cache.ServerCachePlugin; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; /** * Default implementation of ServerCachePlugin. @@ -14,7 +14,7 @@ public final class DefaultServerCachePlugin implements ServerCachePlugin { * Creates the default ServerCacheFactory. */ @Override - public ServerCacheFactory create(DatabaseConfig config, BackgroundExecutor executor) { + public ServerCacheFactory create(DatabaseBuilder config, BackgroundExecutor executor) { return new DefaultServerCacheFactory(executor); } } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/ClassPathScanners.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/ClassPathScanners.java index 8810465b2..18b6a1d5b 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/ClassPathScanners.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/ClassPathScanners.java @@ -2,7 +2,7 @@ package io.ebeaninternal.server.core; import io.avaje.classpath.scanner.ClassPathScanner; import io.avaje.classpath.scanner.ClassPathScannerFactory; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; import java.util.ArrayList; import java.util.List; @@ -16,7 +16,7 @@ public class ClassPathScanners { /** * Return the list of ClassPathScanner services using DatabaseConfig service loader. */ - public static List find(DatabaseConfig config) { + public static List find(DatabaseBuilder config) { List scanners = new ArrayList<>(); for (ClassPathScannerFactory factory : ServiceLoader.load(ClassPathScannerFactory.class)) { scanners.add(factory.createScanner(config.getClassLoadConfig().getClassLoader())); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/DatabasePlatformFactory.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/DatabasePlatformFactory.java index c12ea58cc..016722848 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/DatabasePlatformFactory.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/DatabasePlatformFactory.java @@ -1,6 +1,6 @@ package io.ebeaninternal.server.core; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; import io.ebean.config.dbplatform.DatabasePlatform; import io.ebean.config.dbplatform.DatabasePlatformProvider; import io.ebeaninternal.api.CoreLog; @@ -37,7 +37,7 @@ public class DatabasePlatformFactory { /** * Create the appropriate database specific platform. */ - public DatabasePlatform create(DatabaseConfig config) { + public DatabasePlatform create(DatabaseBuilder config) { try { String offlinePlatform = DbOffline.getPlatform(); if (offlinePlatform != null) { diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultContainer.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultContainer.java index 103d7b8fc..3cd1c4713 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultContainer.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultContainer.java @@ -1,5 +1,6 @@ package io.ebeaninternal.server.core; +import io.ebean.DatabaseBuilder; import io.ebean.config.*; import io.ebean.config.dbplatform.DatabasePlatform; import io.ebean.event.ShutdownManager; @@ -51,13 +52,13 @@ public final class DefaultContainer implements SpiContainer { */ @Override public SpiEbeanServer createServer(String name) { - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); config.setName(name); config.loadFromProperties(); return createServer(config); } - private SpiBackgroundExecutor createBackgroundExecutor(DatabaseConfig config) { + private SpiBackgroundExecutor createBackgroundExecutor(DatabaseBuilder config) { String namePrefix = "ebean-" + config.getName(); int schedulePoolSize = config.getBackgroundExecutorSchedulePoolSize(); int shutdownSecs = config.getBackgroundExecutorShutdownSecs(); @@ -69,7 +70,7 @@ public final class DefaultContainer implements SpiContainer { * Create the implementation from the configuration. */ @Override - public SpiEbeanServer createServer(DatabaseConfig config) { + public SpiEbeanServer createServer(DatabaseBuilder config) { lock.lock(); try { long start = System.currentTimeMillis(); @@ -115,7 +116,7 @@ public final class DefaultContainer implements SpiContainer { } } - private void applyConfigServices(DatabaseConfig config) { + private void applyConfigServices(DatabaseBuilder config) { if (config.isDefaultServer()) { for (DatabaseConfigProvider configProvider : ServiceLoader.load(DatabaseConfigProvider.class)) { configProvider.apply(config); @@ -158,7 +159,7 @@ public final class DefaultContainer implements SpiContainer { * Get the entities, scalarTypes, Listeners etc combining the class registered * ones with the already created instances. */ - private BootupClasses bootupClasses(DatabaseConfig config) { + private BootupClasses bootupClasses(DatabaseBuilder config) { BootupClasses bootup = bootupClasses1(config); bootup.addServerConfigStartup(config.getServerConfigStartupListeners()); bootup.runServerConfigStartup(config); @@ -176,7 +177,7 @@ public final class DefaultContainer implements SpiContainer { /** * Get the class based entities, scalarTypes, Listeners etc. */ - private BootupClasses bootupClasses1(DatabaseConfig config) { + private BootupClasses bootupClasses1(DatabaseBuilder config) { Set> classes = config.classes(); if (config.isDisableClasspathSearch() || (classes != null && !classes.isEmpty())) { // use classes we explicitly added via configuration @@ -188,7 +189,7 @@ public final class DefaultContainer implements SpiContainer { /** * Set the naming convention to underscore if it has not already been set. */ - private void setNamingConvention(DatabaseConfig config) { + private void setNamingConvention(DatabaseBuilder config) { if (config.getNamingConvention() == null) { config.setNamingConvention(new UnderscoreNamingConvention()); } @@ -197,7 +198,7 @@ public final class DefaultContainer implements SpiContainer { /** * Set the DatabasePlatform if it has not already been set. */ - private void setDatabasePlatform(DatabaseConfig config) { + private void setDatabasePlatform(DatabaseBuilder config) { DatabasePlatform platform = config.getDatabasePlatform(); if (platform == null) { if (config.getTenantMode().isDynamicDataSource()) { @@ -213,7 +214,7 @@ public final class DefaultContainer implements SpiContainer { /** * Set the DataSource if it has not already been set. */ - private void setDataSource(DatabaseConfig config) { + private void setDataSource(DatabaseBuilder config) { if (isOfflineMode(config)) { log.log(DEBUG, "... DbOffline using platform [{0}]", DbOffline.getPlatform()); } else { @@ -221,7 +222,7 @@ public final class DefaultContainer implements SpiContainer { } } - private boolean isOfflineMode(DatabaseConfig config) { + private boolean isOfflineMode(DatabaseBuilder config) { return config.isDbOffline() || DbOffline.isSet(); } @@ -235,7 +236,7 @@ public final class DefaultContainer implements SpiContainer { * checking may not work as expected. *

*/ - private boolean checkDataSource(DatabaseConfig config) { + private boolean checkDataSource(DatabaseBuilder config) { if (isOfflineMode(config)) { return false; } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java index cf34addef..b9927be90 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java @@ -76,7 +76,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { private static final System.Logger log = CoreLog.internal; private final ReentrantLock lock = new ReentrantLock(); - private final DatabaseConfig config; + private final DatabaseBuilder config; private final String serverName; private final DatabasePlatform databasePlatform; private final TransactionManager transactionManager; @@ -170,7 +170,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { /** * Create the CallStackFactory depending if AutoTune is being used. */ - private CallOriginFactory initCallStackFactory(DatabaseConfig config) { + private CallOriginFactory initCallStackFactory(DatabaseBuilder config) { if (!config.getAutoTuneConfig().isActive()) { // use a common CallStack for performance as we don't care with no AutoTune return new NoopCallOriginFactory(); @@ -224,7 +224,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { } @Override - public DatabaseConfig config() { + public DatabaseBuilder config() { return config; } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/InitDataSource.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/InitDataSource.java index 1c8837919..631c0b7d8 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/InitDataSource.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/InitDataSource.java @@ -1,7 +1,7 @@ package io.ebeaninternal.server.core; import io.ebean.annotation.Platform; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; import io.ebean.datasource.*; import jakarta.persistence.PersistenceException; @@ -12,16 +12,16 @@ import javax.sql.DataSource; */ final class InitDataSource { - private final DatabaseConfig config; + private final DatabaseBuilder config; /** * Create and set the main DataSource and read-only DataSource. */ - static void init(DatabaseConfig config) { + static void init(DatabaseBuilder config) { new InitDataSource(config).initialise(); } - InitDataSource(DatabaseConfig config) { + InitDataSource(DatabaseBuilder config) { this.config = config; } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/InternalConfiguration.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/InternalConfiguration.java index f214e3fd8..cf49f1637 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/InternalConfiguration.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/InternalConfiguration.java @@ -1,13 +1,11 @@ package io.ebeaninternal.server.core; import com.fasterxml.jackson.core.JsonFactory; +import io.ebean.DatabaseBuilder; import io.ebean.ExpressionFactory; import io.ebean.annotation.Platform; import io.ebean.cache.*; -import io.ebean.config.DatabaseConfig; -import io.ebean.config.ExternalTransactionManager; -import io.ebean.config.ProfilingConfig; -import io.ebean.config.SlowQueryListener; +import io.ebean.config.*; import io.ebean.config.dbplatform.DatabasePlatform; import io.ebean.config.dbplatform.DbHistorySupport; import io.ebean.event.changelog.ChangeLogListener; @@ -71,7 +69,7 @@ public final class InternalConfiguration { private final TableModState tableModState; private final boolean online; - private final DatabaseConfig config; + private final DatabaseBuilder config; private final BootupClasses bootupClasses; private final DatabasePlatform databasePlatform; private final DeployInherit deployInherit; @@ -100,7 +98,7 @@ public final class InternalConfiguration { private boolean localL2Caching; InternalConfiguration(boolean online, ClusterManager clusterManager, SpiBackgroundExecutor backgroundExecutor, - DatabaseConfig config, BootupClasses bootupClasses) { + DatabaseBuilder config, BootupClasses bootupClasses) { this.online = online; this.config = config; @@ -175,7 +173,7 @@ public final class InternalConfiguration { /** * Create and return the ExpressionFactory based on configuration and database platform. */ - private ExpressionFactory initExpressionFactory(DatabaseConfig config) { + private ExpressionFactory initExpressionFactory(DatabaseBuilder config) { boolean nativeIlike = config.isExpressionNativeIlike() && databasePlatform.supportsNativeIlike(); return new DefaultExpressionFactory(config.isExpressionEqualsWithNullAsNoop(), nativeIlike); } @@ -333,7 +331,7 @@ public final class InternalConfiguration { return config.getDatabasePlatform(); } - public DatabaseConfig getConfig() { + public DatabaseBuilder getConfig() { return config; } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/bootup/BootupClassPathSearch.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/bootup/BootupClassPathSearch.java index 8e2dd4d7f..7d0b43c5f 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/bootup/BootupClassPathSearch.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/bootup/BootupClassPathSearch.java @@ -1,7 +1,7 @@ package io.ebeaninternal.server.core.bootup; import io.avaje.classpath.scanner.ClassPathScanner; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; import io.ebeaninternal.api.CoreLog; import io.ebeaninternal.server.core.ClassPathScanners; @@ -24,11 +24,11 @@ public class BootupClassPathSearch { * Search the classPath for the classes we are interested in returning * them as BootupClasses. */ - public static BootupClasses search(DatabaseConfig config) { + public static BootupClasses search(DatabaseBuilder config) { return new BootupClassPathSearch(config).getBootupClasses(); } - private BootupClassPathSearch(DatabaseConfig config) { + private BootupClassPathSearch(DatabaseBuilder config) { // find packages defined in ebean.mf resources Set mfPackages = ManifestReader.create(config.getClassLoadConfig().getClassLoader()) .read("META-INF/ebean.mf") diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/bootup/BootupClasses.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/bootup/BootupClasses.java index c5a2c4134..0a01cfa4a 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/bootup/BootupClasses.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/bootup/BootupClasses.java @@ -1,7 +1,7 @@ package io.ebeaninternal.server.core.bootup; import io.ebean.annotation.DocStore; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; import io.ebean.config.IdGenerator; import io.ebean.config.ScalarTypeConverter; import io.ebean.core.type.ScalarType; @@ -91,7 +91,7 @@ public class BootupClasses implements Predicate> { /** * Run any ServerConfigStartup listeners. */ - public void runServerConfigStartup(DatabaseConfig config) { + public void runServerConfigStartup(DatabaseBuilder config) { for (Class cls : serverConfigStartupCandidates) { try { ServerConfigStartup newInstance = (ServerConfigStartup) cls.getDeclaredConstructor().newInstance(); @@ -172,7 +172,7 @@ public class BootupClasses implements Predicate> { add(startupInstances, serverConfigStartupInstances, serverConfigStartupCandidates); } - public void addChangeLogInstances(DatabaseConfig config) { + public void addChangeLogInstances(DatabaseBuilder config) { readAuditPrepare = config.getReadAuditPrepare(); readAuditLogger = config.getReadAuditLogger(); changeLogPrepare = config.getChangeLogPrepare(); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptor.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptor.java index 23f05b2e9..9efe9f306 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptor.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptor.java @@ -4,7 +4,7 @@ import io.ebean.*; import io.ebean.annotation.DocStoreMode; import io.ebean.bean.*; import io.ebean.cache.QueryCacheEntry; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; import io.ebean.config.EncryptKey; import io.ebean.config.dbplatform.IdType; import io.ebean.config.dbplatform.PlatformIdGenerator; @@ -423,7 +423,7 @@ public class BeanDescriptor implements BeanType, STreeType, SpiBeanType { /** * Return the DatabaseConfig. */ - public DatabaseConfig config() { + public DatabaseBuilder config() { return owner.config(); } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorManager.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorManager.java index c362ed522..ec0aca791 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorManager.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorManager.java @@ -1,6 +1,7 @@ package io.ebeaninternal.server.deploy; import io.ebean.BackgroundExecutor; +import io.ebean.DatabaseBuilder; import io.ebean.Model; import io.ebean.RawSqlBuilder; import io.ebean.annotation.ConstraintMode; @@ -78,7 +79,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy private final NamingConvention namingConvention; private final DeployCreateProperties createProperties; private final BeanManagerFactory beanManagerFactory; - private final DatabaseConfig config; + private final DatabaseBuilder config; private final ChangeLogListener changeLogListener; private final ChangeLogRegister changeLogRegister; private final ChangeLogPrepare changeLogPrepare; @@ -195,7 +196,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy /** * Return the AsOfViewSuffix based on the DbHistorySupport. */ - private String asOfViewSuffix(DatabasePlatform databasePlatform, DatabaseConfig serverConfig) { + private String asOfViewSuffix(DatabasePlatform databasePlatform, DatabaseBuilder serverConfig) { DbHistorySupport historySupport = databasePlatform.historySupport(); // with historySupport returns a simple view suffix or the sql2011 as of timestamp suffix return (historySupport == null) ? serverConfig.getAsOfViewSuffix() : historySupport.getAsOfViewSuffix(serverConfig.getAsOfViewSuffix()); @@ -204,7 +205,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy /** * Return the versions between timestamp suffix based on the DbHistorySupport. */ - private String versionsBetweenSuffix(DatabasePlatform databasePlatform, DatabaseConfig serverConfig) { + private String versionsBetweenSuffix(DatabasePlatform databasePlatform, DatabaseBuilder serverConfig) { DbHistorySupport historySupport = databasePlatform.historySupport(); // with historySupport returns a simple view suffix or the sql2011 versions between timestamp suffix return (historySupport == null) ? serverConfig.getAsOfViewSuffix() : historySupport.getVersionsBetweenSuffix(serverConfig.getAsOfViewSuffix()); @@ -216,7 +217,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy } @Override - public DatabaseConfig config() { + public DatabaseBuilder config() { return config; } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorMap.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorMap.java index e5ba63521..5aa2d0166 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorMap.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorMap.java @@ -1,6 +1,6 @@ package io.ebeaninternal.server.deploy; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; import io.ebean.config.EncryptKey; import io.ebean.config.NamingConvention; import io.ebean.core.type.ScalarType; @@ -25,7 +25,7 @@ public interface BeanDescriptorMap { /** * Return the DatabaseConfig. */ - DatabaseConfig config(); + DatabaseBuilder config(); /** * Return the Cache Manager. diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanLifecycleAdapterFactory.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanLifecycleAdapterFactory.java index 7676814f5..4de9279b3 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanLifecycleAdapterFactory.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanLifecycleAdapterFactory.java @@ -2,7 +2,7 @@ package io.ebeaninternal.server.deploy; import io.ebean.annotation.PostSoftDelete; import io.ebean.annotation.PreSoftDelete; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; import io.ebean.event.BeanPersistAdapter; import io.ebean.event.BeanPersistRequest; import io.ebean.event.BeanPostConstructListener; @@ -34,7 +34,7 @@ final class BeanLifecycleAdapterFactory { private final boolean postConstructPresent; - BeanLifecycleAdapterFactory(DatabaseConfig config) { + BeanLifecycleAdapterFactory(DatabaseBuilder config) { this.postConstructPresent = config.getClassLoadConfig().isJavaxPostConstructPresent(); } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/generatedproperty/GeneratedPropertyFactory.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/generatedproperty/GeneratedPropertyFactory.java index 0f81b4060..b920054cf 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/generatedproperty/GeneratedPropertyFactory.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/generatedproperty/GeneratedPropertyFactory.java @@ -1,10 +1,8 @@ package io.ebeaninternal.server.deploy.generatedproperty; +import io.ebean.DatabaseBuilder; import io.ebean.Transaction; -import io.ebean.config.ClassLoadConfig; -import io.ebean.config.CurrentUserProvider; -import io.ebean.config.DatabaseConfig; -import io.ebean.config.IdGenerator; +import io.ebean.config.*; import io.ebean.config.dbplatform.PlatformIdGenerator; import io.ebeaninternal.server.deploy.meta.DeployBeanProperty; @@ -29,7 +27,7 @@ public final class GeneratedPropertyFactory { private final ClassLoadConfig classLoadConfig; private final Map idGeneratorMap = new HashMap<>(); - public GeneratedPropertyFactory(boolean offlineMode, DatabaseConfig config, List idGenerators) { + public GeneratedPropertyFactory(boolean offlineMode, DatabaseBuilder config, List idGenerators) { this.classLoadConfig = config.getClassLoadConfig(); this.insertFactory = new InsertTimestampFactory(classLoadConfig); this.updateFactory = new UpdateTimestampFactory(classLoadConfig); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanDescriptor.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanDescriptor.java index f9715f2aa..ecc455152 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanDescriptor.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanDescriptor.java @@ -4,7 +4,7 @@ import io.ebean.annotation.Cache; import io.ebean.annotation.DocStore; import io.ebean.annotation.DocStoreMode; import io.ebean.annotation.Identity; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; import io.ebean.config.TableName; import io.ebean.config.dbplatform.IdType; import io.ebean.config.dbplatform.PlatformIdGenerator; @@ -47,7 +47,7 @@ public class DeployBeanDescriptor { private static final PropOrder PROP_ORDER = new PropOrder(); - private final DatabaseConfig config; + private final DatabaseBuilder config; private final BeanDescriptorManager manager; /** * Map of BeanProperty Linked so as to preserve order. @@ -133,7 +133,7 @@ public class DeployBeanDescriptor { /** * Construct the BeanDescriptor. */ - public DeployBeanDescriptor(BeanDescriptorManager manager, Class beanType, DatabaseConfig config) { + public DeployBeanDescriptor(BeanDescriptorManager manager, Class beanType, DatabaseBuilder config) { this.manager = manager; this.config = config; this.beanType = beanType; diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/DeployUtil.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/DeployUtil.java index b05d1933f..d728344f0 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/DeployUtil.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/DeployUtil.java @@ -1,13 +1,8 @@ package io.ebeaninternal.server.deploy.parse; +import io.ebean.DatabaseBuilder; import io.ebean.annotation.*; -import io.ebean.config.DatabaseConfig; -import io.ebean.config.EncryptDeploy; -import io.ebean.config.EncryptDeployManager; -import io.ebean.config.EncryptKeyManager; -import io.ebean.config.Encryptor; -import io.ebean.config.NamingConvention; -import io.ebean.config.TableName; +import io.ebean.config.*; import io.ebean.config.dbplatform.DatabasePlatform; import io.ebean.config.dbplatform.DbPlatformType; import io.ebean.core.type.ScalarType; @@ -49,7 +44,7 @@ public final class DeployUtil { private final Encryptor bytesEncryptor; private final boolean useValidationNotNull; - public DeployUtil(TypeManager typeMgr, DatabaseConfig config) { + public DeployUtil(TypeManager typeMgr, DatabaseBuilder config) { this.typeManager = typeMgr; this.namingConvention = config.getNamingConvention(); this.dbPlatform = config.getDatabasePlatform(); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/ReadAnnotationConfig.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/ReadAnnotationConfig.java index 6335cace8..2fd6d1e78 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/ReadAnnotationConfig.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/ReadAnnotationConfig.java @@ -4,7 +4,7 @@ import io.ebean.annotation.Aggregation; import io.ebean.annotation.Formula; import io.ebean.annotation.Where; import io.ebean.config.ClassLoadConfig; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; import io.ebeaninternal.server.deploy.generatedproperty.GeneratedPropertyFactory; import io.ebeaninternal.server.deploy.meta.DeployBeanProperty; @@ -31,7 +31,7 @@ final class ReadAnnotationConfig { private final ReadValidationAnnotations jakartaValidation; private final Set> metaAnnotations = new HashSet<>(); - ReadAnnotationConfig(GeneratedPropertyFactory generatedPropFactory, String asOfViewSuffix, String versionsBetweenSuffix, DatabaseConfig config) { + ReadAnnotationConfig(GeneratedPropertyFactory generatedPropFactory, String asOfViewSuffix, String versionsBetweenSuffix, DatabaseBuilder config) { this.generatedPropFactory = generatedPropFactory; this.asOfViewSuffix = asOfViewSuffix; this.versionsBetweenSuffix = versionsBetweenSuffix; diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/ReadAnnotations.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/ReadAnnotations.java index 3d8932933..5bb7ae54d 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/ReadAnnotations.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/ReadAnnotations.java @@ -1,6 +1,6 @@ package io.ebeaninternal.server.deploy.parse; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; import io.ebeaninternal.server.deploy.BeanDescriptorManager; import io.ebeaninternal.server.deploy.generatedproperty.GeneratedPropertyFactory; @@ -12,7 +12,7 @@ public final class ReadAnnotations { private final ReadAnnotationConfig readConfig; - public ReadAnnotations(GeneratedPropertyFactory generatedPropFactory, String asOfViewSuffix, String versionsBetweenSuffix, DatabaseConfig config) { + public ReadAnnotations(GeneratedPropertyFactory generatedPropFactory, String asOfViewSuffix, String versionsBetweenSuffix, DatabaseBuilder config) { this.readConfig = new ReadAnnotationConfig(generatedPropFactory, asOfViewSuffix, versionsBetweenSuffix, config); } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryEngine.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryEngine.java index 82eb66453..73a1d9a2d 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryEngine.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryEngine.java @@ -7,7 +7,7 @@ import io.ebean.annotation.Platform; import io.ebean.bean.BeanCollection; import io.ebean.bean.EntityBean; import io.ebean.bean.ObjectGraphNode; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; import io.ebean.config.dbplatform.DatabasePlatform; import io.ebean.util.JdbcClose; import io.ebean.util.StringHelper; @@ -38,7 +38,7 @@ public final class CQueryEngine { private final CQueryHistorySupport historySupport; private final DatabasePlatform dbPlatform; - public CQueryEngine(DatabaseConfig config, DatabasePlatform dbPlatform, Binder binder, Map asOfTableMapping, Map draftTableMap) { + public CQueryEngine(DatabaseBuilder config, DatabasePlatform dbPlatform, Binder binder, Map asOfTableMapping, Map draftTableMap) { this.dbPlatform = dbPlatform; this.defaultFetchSizeFindEach = config.getJdbcFetchSizeFindEach(); this.defaultFetchSizeFindList = config.getJdbcFetchSizeFindList(); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/TransactionManagerOptions.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/TransactionManagerOptions.java index b7d54b37e..f94bbd345 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/TransactionManagerOptions.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/TransactionManagerOptions.java @@ -2,7 +2,7 @@ package io.ebeaninternal.server.transaction; import io.ebean.BackgroundExecutor; import io.ebean.cache.ServerCacheNotify; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; import io.ebean.plugin.SpiServer; import io.ebeaninternal.api.SpiLogManager; import io.ebeaninternal.api.SpiProfileHandler; @@ -18,7 +18,7 @@ public final class TransactionManagerOptions { final SpiServer server; final boolean notifyL2CacheInForeground; - final DatabaseConfig config; + final DatabaseBuilder config; final ClusterManager clusterManager; final BackgroundExecutor backgroundExecutor; @@ -33,7 +33,7 @@ public final class TransactionManagerOptions { final ClockService clockService; - public TransactionManagerOptions(SpiServer server, boolean notifyL2CacheInForeground, DatabaseConfig config, TransactionScopeManager scopeManager, ClusterManager clusterManager, + public TransactionManagerOptions(SpiServer server, boolean notifyL2CacheInForeground, DatabaseBuilder config, TransactionScopeManager scopeManager, ClusterManager clusterManager, BackgroundExecutor backgroundExecutor, DocStoreUpdateProcessor docStoreUpdateProcessor, BeanDescriptorManager descMgr, DataSourceSupplier dataSourceSupplier, SpiProfileHandler profileHandler, SpiLogManager logManager, TableModState tableModState, ServerCacheNotify cacheNotify, ClockService clockService) { diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/type/DefaultTypeFactory.java b/ebean-core/src/main/java/io/ebeaninternal/server/type/DefaultTypeFactory.java index af89523ab..881021efe 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/type/DefaultTypeFactory.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/type/DefaultTypeFactory.java @@ -1,6 +1,6 @@ package io.ebeaninternal.server.type; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; import io.ebean.config.JsonConfig; import io.ebean.core.type.ScalarType; import io.ebean.core.type.BasicTypeConverter; @@ -16,9 +16,9 @@ import java.util.Date; */ final class DefaultTypeFactory { - private final DatabaseConfig config; + private final DatabaseBuilder config; - public DefaultTypeFactory(DatabaseConfig config) { + public DefaultTypeFactory(DatabaseBuilder config) { this.config = config; } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/type/DefaultTypeManager.java b/ebean-core/src/main/java/io/ebeaninternal/server/type/DefaultTypeManager.java index f79245e54..4cc68f665 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/type/DefaultTypeManager.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/type/DefaultTypeManager.java @@ -1,11 +1,9 @@ package io.ebeaninternal.server.type; import com.fasterxml.jackson.databind.ObjectMapper; +import io.ebean.DatabaseBuilder; import io.ebean.annotation.*; -import io.ebean.config.DatabaseConfig; -import io.ebean.config.JsonConfig; -import io.ebean.config.PlatformConfig; -import io.ebean.config.ScalarTypeConverter; +import io.ebean.config.*; import io.ebean.config.dbplatform.DatabasePlatform; import io.ebean.config.dbplatform.DbPlatformType; import io.ebean.core.type.*; @@ -78,7 +76,7 @@ public final class DefaultTypeManager implements TypeManager { /** * Create the DefaultTypeManager. */ - public DefaultTypeManager(DatabaseConfig config, BootupClasses bootupClasses) { + public DefaultTypeManager(DatabaseBuilder config, BootupClasses bootupClasses) { this.jsonDateTime = config.getJsonDateTime(); this.jsonDate = config.getJsonDate(); this.typeMap = new ConcurrentHashMap<>(); @@ -110,7 +108,7 @@ public final class DefaultTypeManager implements TypeManager { } } - private void loadGeoTypeBinder(DatabaseConfig config) { + private void loadGeoTypeBinder(DatabaseBuilder config) { GeoTypeProvider provider = config.getServiceObject(GeoTypeProvider.class); if (provider == null) { provider = ServiceUtil.service(GeoTypeProvider.class); @@ -141,7 +139,7 @@ public final class DefaultTypeManager implements TypeManager { /** * Load custom scalar types registered via ExtraTypeFactory and ServiceLoader. */ - private void loadTypesFromProviders(DatabaseConfig config, Object objectMapper) { + private void loadTypesFromProviders(DatabaseBuilder config, Object objectMapper) { for (ExtraTypeFactory plugin : ServiceLoader.load(ExtraTypeFactory.class)) { for (ScalarType type : plugin.createTypes(config, objectMapper)) { add(type); @@ -618,7 +616,7 @@ public final class DefaultTypeManager implements TypeManager { } - private Object initObjectMapper(DatabaseConfig config) { + private Object initObjectMapper(DatabaseBuilder config) { Object objectMapper = config.getObjectMapper(); if (objectMapper == null) { objectMapper = InitObjectMapper.init(); @@ -676,7 +674,7 @@ public final class DefaultTypeManager implements TypeManager { } - private void initialiseJavaTimeTypes(DatabaseConfig config) { + private void initialiseJavaTimeTypes(DatabaseBuilder config) { ZoneId zoneId = zoneId(config); typeMap.put(java.nio.file.Path.class, new ScalarTypePath()); @@ -704,7 +702,7 @@ public final class DefaultTypeManager implements TypeManager { addType(Duration.class, (durationNanos) ? new ScalarTypeDurationWithNanos() : new ScalarTypeDuration()); } - private ZoneId zoneId(DatabaseConfig config) { + private ZoneId zoneId(DatabaseBuilder config) { final String dataTimeZone = config.getDataTimeZone(); return (dataTimeZone == null) ? ZoneOffset.systemDefault() : TimeZone.getTimeZone(dataTimeZone).toZoneId(); } @@ -718,7 +716,7 @@ public final class DefaultTypeManager implements TypeManager { * Register all the standard types supported. This is the standard JDBC types * plus some other common types such as java.util.Date and java.util.Calendar. */ - private void initialiseStandard(DatabaseConfig config) { + private void initialiseStandard(DatabaseBuilder config) { DatabasePlatform databasePlatform = config.getDatabasePlatform(); int platformClobType = databasePlatform.clobDbType(); int platformBlobType = databasePlatform.blobDbType(); diff --git a/ebean-core/src/test/java/io/ebeaninternal/server/core/InitDataSourceTest.java b/ebean-core/src/test/java/io/ebeaninternal/server/core/InitDataSourceTest.java index 3bf3f6c50..1a3f620ea 100644 --- a/ebean-core/src/test/java/io/ebeaninternal/server/core/InitDataSourceTest.java +++ b/ebean-core/src/test/java/io/ebeaninternal/server/core/InitDataSourceTest.java @@ -1,5 +1,6 @@ package io.ebeaninternal.server.core; +import io.ebean.DatabaseBuilder; import io.ebean.config.DatabaseConfig; import io.ebean.datasource.DataSourceAlert; import io.ebean.datasource.DataSourceBuilder; @@ -18,8 +19,8 @@ import static org.junit.jupiter.api.Assertions.*; public class InitDataSourceTest { - private DatabaseConfig newConfig(String readOnlyUrl) { - DatabaseConfig config = new DatabaseConfig(); + private DatabaseBuilder newConfig(String readOnlyUrl) { + DatabaseBuilder config = new DatabaseConfig(); DataSourceConfig roConfig = new DataSourceConfig(); roConfig.setUrl(readOnlyUrl); config.setReadOnlyDataSourceConfig(roConfig); @@ -34,7 +35,7 @@ public class InitDataSourceTest { @Test public void readOnlyConfig_null_whenSetNullExplicitly() { - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); config.setReadOnlyDataSourceConfig(null); assertNull(new InitDataSource(config).readOnlyConfig()); @@ -56,7 +57,7 @@ public class InitDataSourceTest { @Test public void readOnlyConfig_when_autoReadOnlyDataSource() { - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); config.setAutoReadOnlyDataSource(true); assertNotNull(new InitDataSource(config).readOnlyConfig()); @@ -64,7 +65,7 @@ public class InitDataSourceTest { @Test public void readOnlyConfig_when_autoReadOnlyDataSource_expect_setToNull() { - DatabaseConfig config = newConfig("none"); + DatabaseBuilder config = newConfig("none"); config.setAutoReadOnlyDataSource(true); final DataSourceBuilder readOnlyConfig = new InitDataSource(config).readOnlyConfig(); @@ -74,7 +75,7 @@ public class InitDataSourceTest { @Test public void readOnlyConfig_when_urlSet() { - DatabaseConfig config = newConfig("foo"); + DatabaseBuilder config = newConfig("foo"); final DataSourceBuilder roConfig = new InitDataSource(config).readOnlyConfig(); assertNotNull(roConfig); @@ -83,7 +84,7 @@ public class InitDataSourceTest { @Test public void readOnlyConfig_when_readOnlyUrlSetOnMain() { - DatabaseConfig config = newConfig(null); + DatabaseBuilder config = newConfig(null); // alternate location to set read-only url for developer convenience config.getDataSourceConfig().readOnlyUrl("bar"); @@ -94,7 +95,7 @@ public class InitDataSourceTest { @Test public void readOnlyConfig_when_readOnlyUrlSetOnMain_withNone() { - DatabaseConfig config = newConfig("None"); + DatabaseBuilder config = newConfig("None"); // alternate location to set read-only url for developer convenience config.getDataSourceConfig().readOnlyUrl("bar"); @@ -105,7 +106,7 @@ public class InitDataSourceTest { @Test public void readOnlyConfig_when_bothReadOnlyUrlsSet() { - DatabaseConfig config = newConfig("one"); + DatabaseBuilder config = newConfig("one"); config.getDataSourceConfig().readOnlyUrl("two"); final DataSourceBuilder roConfig = new InitDataSource(config).readOnlyConfig(); @@ -115,7 +116,7 @@ public class InitDataSourceTest { @Test public void readOnlyConfig_when_readOnlyUrlSetOnMain_withNoneNone() { - DatabaseConfig config = newConfig("none"); + DatabaseBuilder config = newConfig("none"); // alternate location to set read-only url for developer convenience config.getDataSourceConfig().readOnlyUrl("none"); @@ -125,7 +126,7 @@ public class InitDataSourceTest { @Test public void readOnlyConfig_when_urlSet_2() { - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); config.getReadOnlyDataSourceConfig().url("foo"); final DataSourceBuilder roConfig = new InitDataSource(config).readOnlyConfig(); @@ -135,7 +136,7 @@ public class InitDataSourceTest { @Test void isPostgresAllQuotedIdentifiers_true_when_postgres() { - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); config.setAllQuotedIdentifiers(true); config.setDatabasePlatform(new PostgresPlatform()); @@ -144,7 +145,7 @@ public class InitDataSourceTest { @Test void isPostgresAllQuotedIdentifiers_true_when_postgres9() { - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); config.setAllQuotedIdentifiers(true); config.setDatabasePlatform(new Postgres9Platform()); @@ -153,7 +154,7 @@ public class InitDataSourceTest { @Test void isPostgresAllQuotedIdentifiers_false() { - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); config.setAllQuotedIdentifiers(false); config.setDatabasePlatform(new PostgresPlatform()); @@ -162,7 +163,7 @@ public class InitDataSourceTest { @Test void isPostgresAllQuotedIdentifiers_false_when_notPostgres() { - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); config.setAllQuotedIdentifiers(true); config.setDatabasePlatform(new H2Platform()); @@ -171,7 +172,7 @@ public class InitDataSourceTest { @Test public void online() { - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); config.getDataSourceConfig().username("sa"); config.getDataSourceConfig().password(""); config.getDataSourceConfig().url("jdbc:h2:mem:dsTestOnline"); @@ -203,7 +204,7 @@ public class InitDataSourceTest { @Test public void offline() throws SQLException { - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); DataSourceBuilder dsConfig = config.getDataSourceConfig(); dsConfig.username("sa"); dsConfig.password(""); 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 24301ba46..255d15985 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,6 +1,7 @@ package io.ebeaninternal.server.deploy; import io.ebean.DatabaseFactory; +import io.ebean.DatabaseBuilder; import io.ebean.config.DatabaseConfig; import io.ebean.event.AbstractBeanPersistListener; import io.ebean.event.BeanPersistAdapter; @@ -17,7 +18,7 @@ public class BeanDescriptor_registerTest { @Test public void testRegisterDeregister() { - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); config.setName("h2other"); config.loadFromProperties(); diff --git a/ebean-core/src/test/java/io/ebeaninternal/server/deploy/parse/AnnotationClassTest.java b/ebean-core/src/test/java/io/ebeaninternal/server/deploy/parse/AnnotationClassTest.java index 516081d3f..78a9e6b90 100644 --- a/ebean-core/src/test/java/io/ebeaninternal/server/deploy/parse/AnnotationClassTest.java +++ b/ebean-core/src/test/java/io/ebeaninternal/server/deploy/parse/AnnotationClassTest.java @@ -1,5 +1,6 @@ package io.ebeaninternal.server.deploy.parse; +import io.ebean.DatabaseBuilder; import io.ebean.config.DatabaseConfig; import io.ebean.platform.sqlserver.SqlServer17Platform; import io.ebeaninternal.server.core.bootup.BootupClasses; @@ -45,7 +46,7 @@ public class AnnotationClassTest { } @SuppressWarnings({"unchecked", "rawtypes"}) - private AnnotationClass createAnnotationClass(DatabaseConfig config) { + private AnnotationClass createAnnotationClass(DatabaseBuilder config) { DeployUtil deployUtil = new DeployUtil(new DefaultTypeManager(config, new BootupClasses()), config); DeployBeanInfo deployBeanInfo = new DeployBeanInfo(deployUtil, new DeployBeanDescriptor<>(null, Customer.class, null)); @@ -53,9 +54,9 @@ public class AnnotationClassTest { return new AnnotationClass(deployBeanInfo, readAnnotationConfig); } - private DatabaseConfig sqlServerPlatform(boolean allQuotedIdentifiers) { + private DatabaseBuilder sqlServerPlatform(boolean allQuotedIdentifiers) { SqlServer17Platform sqlServer17Platform = new SqlServer17Platform(); - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); config.setDatabasePlatform(sqlServer17Platform); config.setAllQuotedIdentifiers(allQuotedIdentifiers); diff --git a/ebean-core/src/test/java/io/ebeaninternal/server/type/DefaultTypeManagerTest.java b/ebean-core/src/test/java/io/ebeaninternal/server/type/DefaultTypeManagerTest.java index 2a89f0f38..68adea658 100644 --- a/ebean-core/src/test/java/io/ebeaninternal/server/type/DefaultTypeManagerTest.java +++ b/ebean-core/src/test/java/io/ebeaninternal/server/type/DefaultTypeManagerTest.java @@ -1,5 +1,6 @@ package io.ebeaninternal.server.type; +import io.ebean.DatabaseBuilder; import io.ebean.config.DatabaseConfig; import io.ebean.platform.postgres.PostgresPlatform; import io.ebean.core.type.ScalarType; @@ -20,7 +21,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; public class DefaultTypeManagerTest { private DefaultTypeManager create() { - DatabaseConfig serverConfig = new DatabaseConfig(); + DatabaseBuilder serverConfig = new DatabaseConfig(); serverConfig.setDatabasePlatform(new PostgresPlatform()); BootupClasses bootupClasses = new BootupClasses(); return new DefaultTypeManager(serverConfig, bootupClasses); diff --git a/ebean-core/src/test/java/io/ebeaninternal/server/type/TestTypeManager.java b/ebean-core/src/test/java/io/ebeaninternal/server/type/TestTypeManager.java index 9a357fe01..b6c1e0bf2 100644 --- a/ebean-core/src/test/java/io/ebeaninternal/server/type/TestTypeManager.java +++ b/ebean-core/src/test/java/io/ebeaninternal/server/type/TestTypeManager.java @@ -1,5 +1,6 @@ package io.ebeaninternal.server.type; +import io.ebean.DatabaseBuilder; import io.ebean.config.DatabaseConfig; import io.ebean.platform.h2.H2Platform; import io.ebean.core.type.DataReader; @@ -121,7 +122,7 @@ class TestTypeManager extends BaseTest { } private DefaultTypeManager createTypeManager() { - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); config.setDatabasePlatform(new H2Platform()); BootupClasses bootupClasses = new BootupClasses(); @@ -131,7 +132,7 @@ class TestTypeManager extends BaseTest { } private DefaultTypeManager createTypeManagerDefaultEnumTypeString() { - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); config.setDatabasePlatform(new H2Platform()); config.setDefaultEnumType(EnumType.STRING); diff --git a/ebean-ddl-generator/src/main/java/io/ebean/dbmigration/DbMigration.java b/ebean-ddl-generator/src/main/java/io/ebean/dbmigration/DbMigration.java index 2a1005fe3..485462067 100644 --- a/ebean-ddl-generator/src/main/java/io/ebean/dbmigration/DbMigration.java +++ b/ebean-ddl-generator/src/main/java/io/ebean/dbmigration/DbMigration.java @@ -2,7 +2,7 @@ package io.ebean.dbmigration; import io.ebean.Database; import io.ebean.annotation.Platform; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; import io.ebean.config.dbplatform.DatabasePlatform; import java.io.File; @@ -109,7 +109,7 @@ public interface DbMigration { /** * Set the DatabaseConfig to use. Usually this is not called explicitly. */ - void setServerConfig(DatabaseConfig config); + void setServerConfig(DatabaseBuilder config); /** * Set the specific platform to generate DDL for. diff --git a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/DdlGenerator.java b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/DdlGenerator.java index 87a811648..bb2516e88 100644 --- a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/DdlGenerator.java +++ b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/DdlGenerator.java @@ -2,7 +2,7 @@ package io.ebeaninternal.dbmigration; import io.avaje.applog.AppLog; import io.ebean.annotation.Platform; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; import io.ebean.config.dbplatform.DatabasePlatform; import io.ebean.ddlrunner.DdlRunner; import io.ebean.ddlrunner.ScriptTransform; @@ -51,7 +51,7 @@ public class DdlGenerator implements SpiDdlGenerator { public DdlGenerator(SpiEbeanServer server) { this.server = server; - final DatabaseConfig config = server.config(); + final DatabaseBuilder config = server.config(); this.jaxbPresent = Detect.isJAXBPresent(config); this.generateDdl = config.isDdlGenerate(); this.extraDdl = config.isDdlExtra(); @@ -318,7 +318,7 @@ public class DdlGenerator implements SpiDdlGenerator { /** * Create the ScriptTransform for placeholder key/value replacement. */ - private ScriptTransform createScriptTransform(DatabaseConfig config) { + private ScriptTransform createScriptTransform(DatabaseBuilder config) { return ScriptTransform.build(config.getDdlPlaceholders(), config.getDdlPlaceholderMap()); } diff --git a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/DefaultDbMigration.java b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/DefaultDbMigration.java index a96957d0a..376aaa748 100644 --- a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/DefaultDbMigration.java +++ b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/DefaultDbMigration.java @@ -3,11 +3,9 @@ package io.ebeaninternal.dbmigration; import io.avaje.applog.AppLog; import io.ebean.DB; import io.ebean.Database; +import io.ebean.DatabaseBuilder; import io.ebean.annotation.Platform; -import io.ebean.config.DatabaseConfig; -import io.ebean.config.DbConstraintNaming; -import io.ebean.config.PlatformConfig; -import io.ebean.config.PropertiesWrapper; +import io.ebean.config.*; import io.ebean.config.dbplatform.DatabasePlatform; import io.ebean.config.dbplatform.DatabasePlatformProvider; import io.ebean.dbmigration.DbMigration; @@ -75,7 +73,7 @@ public class DefaultDbMigration implements DbMigration { protected DatabasePlatform databasePlatform; private boolean vanillaPlatform; protected List platforms = new ArrayList<>(); - protected DatabaseConfig databaseConfig; + protected DatabaseBuilder databaseBuilder; protected DbConstraintNaming constraintNaming; protected Boolean strictMode; protected Boolean includeGeneratedFileComment; @@ -116,12 +114,12 @@ public class DefaultDbMigration implements DbMigration { } @Override - public void setServerConfig(DatabaseConfig config) { - if (this.databaseConfig == null) { - this.databaseConfig = config; + public void setServerConfig(DatabaseBuilder config) { + if (this.databaseBuilder == null) { + this.databaseBuilder = config; } if (constraintNaming == null) { - this.constraintNaming = databaseConfig.getConstraintNaming(); + this.constraintNaming = databaseBuilder.getConstraintNaming(); } Properties properties = config.getProperties(); if (properties != null) { @@ -360,7 +358,7 @@ public class DefaultDbMigration implements DbMigration { */ private void configurePlatforms() { for (Pair pair : platforms) { - PlatformConfig config = databaseConfig.newPlatformConfig("dbmigration.platform", pair.prefix); + PlatformConfig config = databaseBuilder.newPlatformConfig("dbmigration.platform", pair.prefix); pair.platform.configure(config); } } @@ -645,7 +643,7 @@ public class DefaultDbMigration implements DbMigration { } private PlatformDdlWriter createDdlWriter(DatabasePlatform platform) { - return new PlatformDdlWriter(platform, databaseConfig, lockTimeoutSeconds); + return new PlatformDdlWriter(platform, databaseBuilder, lockTimeoutSeconds); } /** @@ -674,12 +672,12 @@ public class DefaultDbMigration implements DbMigration { // not explicitly set so use the platform of the server databasePlatform = server.databasePlatform(); } - if (databaseConfig != null) { + if (databaseBuilder != null) { if (strictMode != null) { - databaseConfig.setDdlStrictMode(strictMode); + databaseBuilder.setDdlStrictMode(strictMode); } if (header != null) { - databaseConfig.setDdlHeader(header); + databaseBuilder.setDdlHeader(header); } } } diff --git a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/Detect.java b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/Detect.java index f7d326c13..0f54abe15 100644 --- a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/Detect.java +++ b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/Detect.java @@ -1,6 +1,6 @@ package io.ebeaninternal.dbmigration; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; /** * Detect existence of JAXB @@ -10,7 +10,7 @@ public class Detect { /** * Return true if JAXB is present. */ - public static boolean isJAXBPresent(DatabaseConfig config) { + public static boolean isJAXBPresent(DatabaseBuilder config) { return config.getClassLoadConfig().isPresent("jakarta.xml.bind.JAXBException"); } } diff --git a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/BaseDdlHandler.java b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/BaseDdlHandler.java index b997689e6..618b5c56f 100644 --- a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/BaseDdlHandler.java +++ b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/BaseDdlHandler.java @@ -1,6 +1,6 @@ package io.ebeaninternal.dbmigration.ddlgeneration; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; import io.ebeaninternal.dbmigration.ddlgeneration.platform.BaseTableDdl; import io.ebeaninternal.dbmigration.ddlgeneration.platform.PlatformDdl; import io.ebeaninternal.dbmigration.migration.*; @@ -14,11 +14,11 @@ public class BaseDdlHandler implements DdlHandler { protected final TableDdl tableDdl; - public BaseDdlHandler(DatabaseConfig config, PlatformDdl platformDdl) { + public BaseDdlHandler(DatabaseBuilder config, PlatformDdl platformDdl) { this(config, platformDdl, new BaseTableDdl(config, platformDdl)); } - protected BaseDdlHandler(DatabaseConfig config, PlatformDdl platformDdl, TableDdl tableDdl) { + protected BaseDdlHandler(DatabaseBuilder config, PlatformDdl platformDdl, TableDdl tableDdl) { this.tableDdl = tableDdl; } diff --git a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/BaseTableDdl.java b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/BaseTableDdl.java index e9fafccc4..4ad068e34 100644 --- a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/BaseTableDdl.java +++ b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/BaseTableDdl.java @@ -1,7 +1,7 @@ package io.ebeaninternal.dbmigration.ddlgeneration.platform; import io.ebean.annotation.Platform; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; import io.ebean.config.DbConstraintNaming; import io.ebean.config.NamingConvention; import io.ebean.util.StringHelper; @@ -155,7 +155,7 @@ public class BaseTableDdl implements TableDdl { /** * Construct with a naming convention and platform specific DDL. */ - public BaseTableDdl(DatabaseConfig config, PlatformDdl platformDdl) { + public BaseTableDdl(DatabaseBuilder config, PlatformDdl platformDdl) { this.namingConvention = config.getNamingConvention(); this.naming = config.getConstraintNaming(); this.historyTableSuffix = config.getHistoryTableSuffix(); diff --git a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/ClickHouseDdl.java b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/ClickHouseDdl.java index 940cdcf24..d39f810d9 100644 --- a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/ClickHouseDdl.java +++ b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/ClickHouseDdl.java @@ -1,6 +1,6 @@ package io.ebeaninternal.dbmigration.ddlgeneration.platform; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; import io.ebean.config.dbplatform.DatabasePlatform; import io.ebeaninternal.dbmigration.ddlgeneration.DdlBuffer; import io.ebeaninternal.dbmigration.ddlgeneration.DdlHandler; @@ -18,7 +18,7 @@ public class ClickHouseDdl extends PlatformDdl { } @Override - public DdlHandler createDdlHandler(DatabaseConfig config) { + public DdlHandler createDdlHandler(DatabaseBuilder config) { return new ClickHouseDdlHandler(config, this); } diff --git a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/ClickHouseDdlHandler.java b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/ClickHouseDdlHandler.java index 6f1eb9bce..813b17828 100644 --- a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/ClickHouseDdlHandler.java +++ b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/ClickHouseDdlHandler.java @@ -1,11 +1,11 @@ package io.ebeaninternal.dbmigration.ddlgeneration.platform; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; import io.ebeaninternal.dbmigration.ddlgeneration.BaseDdlHandler; public class ClickHouseDdlHandler extends BaseDdlHandler { - public ClickHouseDdlHandler(DatabaseConfig config, PlatformDdl platformDdl) { + public ClickHouseDdlHandler(DatabaseBuilder config, PlatformDdl platformDdl) { super(config, platformDdl, new ClickHouseTableDdl(config, platformDdl)); } } diff --git a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/ClickHouseTableDdl.java b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/ClickHouseTableDdl.java index 66a51f2e7..106c2626a 100644 --- a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/ClickHouseTableDdl.java +++ b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/ClickHouseTableDdl.java @@ -1,12 +1,12 @@ package io.ebeaninternal.dbmigration.ddlgeneration.platform; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; import io.ebeaninternal.dbmigration.ddlgeneration.DdlBuffer; import io.ebeaninternal.dbmigration.migration.CreateTable; public class ClickHouseTableDdl extends BaseTableDdl { - public ClickHouseTableDdl(DatabaseConfig config, PlatformDdl platformDdl) { + public ClickHouseTableDdl(DatabaseBuilder config, PlatformDdl platformDdl) { super(config, platformDdl); } diff --git a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/Db2HistoryDdl.java b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/Db2HistoryDdl.java index d246be8b8..b005278ad 100644 --- a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/Db2HistoryDdl.java +++ b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/Db2HistoryDdl.java @@ -1,6 +1,6 @@ package io.ebeaninternal.dbmigration.ddlgeneration.platform; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; import io.ebeaninternal.dbmigration.ddlgeneration.DdlAlterTable; import io.ebeaninternal.dbmigration.ddlgeneration.DdlBuffer; import io.ebeaninternal.dbmigration.ddlgeneration.DdlWrite; @@ -10,7 +10,7 @@ import io.ebeaninternal.dbmigration.model.MTable; /** * DB2 History support. - * + * * @author Roland Praml, FOCONIS AG */ public class Db2HistoryDdl extends DbTableBasedHistoryDdl implements PlatformHistoryDdl { @@ -20,7 +20,7 @@ public class Db2HistoryDdl extends DbTableBasedHistoryDdl implements PlatformHis private String transactionId; @Override - public void configure(DatabaseConfig config, PlatformDdl platformDdl) { + public void configure(DatabaseBuilder config, PlatformDdl platformDdl) { super.configure(config, platformDdl); this.systemPeriodStart = config.getAsOfSysPeriod() + "_start"; this.systemPeriodEnd = config.getAsOfSysPeriod() + "_end"; diff --git a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/DbTableBasedHistoryDdl.java b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/DbTableBasedHistoryDdl.java index 4d7b0deca..6c584878e 100644 --- a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/DbTableBasedHistoryDdl.java +++ b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/DbTableBasedHistoryDdl.java @@ -1,11 +1,11 @@ package io.ebeaninternal.dbmigration.ddlgeneration.platform; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; import io.ebean.config.DbConstraintNaming; /** * Base implementation for all histories, where we must maintain history table (trigger based, db2 and hana) - * + * * @author Roland Praml, FOCONIS AG * */ @@ -16,7 +16,7 @@ public abstract class DbTableBasedHistoryDdl implements PlatformHistoryDdl.Table protected PlatformDdl platformDdl; @Override - public void configure(DatabaseConfig config, PlatformDdl platformDdl) { + public void configure(DatabaseBuilder config, PlatformDdl platformDdl) { this.platformDdl = platformDdl; this.historySuffix = config.getHistoryTableSuffix(); this.constraintNaming = config.getConstraintNaming(); diff --git a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/DbTriggerBasedHistoryDdl.java b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/DbTriggerBasedHistoryDdl.java index 03c2c5d3c..eb85459a8 100644 --- a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/DbTriggerBasedHistoryDdl.java +++ b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/DbTriggerBasedHistoryDdl.java @@ -1,6 +1,6 @@ package io.ebeaninternal.dbmigration.ddlgeneration.platform; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; import io.ebeaninternal.dbmigration.ddlgeneration.DdlAlterTable; import io.ebeaninternal.dbmigration.ddlgeneration.DdlBuffer; import io.ebeaninternal.dbmigration.ddlgeneration.DdlWrite; @@ -28,7 +28,7 @@ public abstract class DbTriggerBasedHistoryDdl extends DbTableBasedHistoryDdl im } @Override - public void configure(DatabaseConfig config, PlatformDdl platformDdl) { + public void configure(DatabaseBuilder config, PlatformDdl platformDdl) { super.configure(config, platformDdl); this.sysPeriod = config.getAsOfSysPeriod(); this.viewSuffix = config.getAsOfViewSuffix(); diff --git a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/HanaHistoryDdl.java b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/HanaHistoryDdl.java index 742f23c45..38daedab2 100644 --- a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/HanaHistoryDdl.java +++ b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/HanaHistoryDdl.java @@ -1,6 +1,6 @@ package io.ebeaninternal.dbmigration.ddlgeneration.platform; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; import io.ebeaninternal.dbmigration.ddlgeneration.DdlAlterTable; import io.ebeaninternal.dbmigration.ddlgeneration.DdlBuffer; import io.ebeaninternal.dbmigration.ddlgeneration.DdlWrite; @@ -17,7 +17,7 @@ public class HanaHistoryDdl extends DbTableBasedHistoryDdl implements PlatformHi private String systemPeriodEnd; @Override - public void configure(DatabaseConfig config, PlatformDdl platformDdl) { + public void configure(DatabaseBuilder config, PlatformDdl platformDdl) { super.configure(config, platformDdl); this.systemPeriodStart = config.getAsOfSysPeriod() + "_start"; this.systemPeriodEnd = config.getAsOfSysPeriod() + "_end"; diff --git a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/MariaDbHistoryDdl.java b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/MariaDbHistoryDdl.java index 31d3cdd91..1faffeb64 100644 --- a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/MariaDbHistoryDdl.java +++ b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/MariaDbHistoryDdl.java @@ -1,6 +1,6 @@ package io.ebeaninternal.dbmigration.ddlgeneration.platform; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; import io.ebeaninternal.dbmigration.ddlgeneration.DdlAlterTable; import io.ebeaninternal.dbmigration.ddlgeneration.DdlBuffer; import io.ebeaninternal.dbmigration.ddlgeneration.DdlWrite; @@ -16,7 +16,7 @@ public class MariaDbHistoryDdl implements PlatformHistoryDdl { private PlatformDdl platformDdl; @Override - public void configure(DatabaseConfig config, PlatformDdl platformDdl) { + public void configure(DatabaseBuilder config, PlatformDdl platformDdl) { this.platformDdl = platformDdl; } diff --git a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/NoHistorySupportDdl.java b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/NoHistorySupportDdl.java index b580f20cb..10d08718f 100644 --- a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/NoHistorySupportDdl.java +++ b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/NoHistorySupportDdl.java @@ -1,6 +1,6 @@ package io.ebeaninternal.dbmigration.ddlgeneration.platform; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; import io.ebeaninternal.dbmigration.ddlgeneration.DdlWrite; import io.ebeaninternal.dbmigration.migration.AddHistoryTable; import io.ebeaninternal.dbmigration.migration.DropHistoryTable; @@ -13,7 +13,7 @@ import io.ebeaninternal.dbmigration.model.MTable; public class NoHistorySupportDdl implements PlatformHistoryDdl { @Override - public void configure(DatabaseConfig config, PlatformDdl platformDdl) { + public void configure(DatabaseBuilder config, PlatformDdl platformDdl) { // does nothing } diff --git a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl.java b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl.java index 7682e71e2..9efc25123 100644 --- a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl.java +++ b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl.java @@ -2,7 +2,7 @@ package io.ebeaninternal.dbmigration.ddlgeneration.platform; import io.ebean.annotation.ConstraintMode; import io.ebean.annotation.Platform; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; import io.ebean.config.DbConstraintNaming; import io.ebean.config.dbplatform.DatabasePlatform; import io.ebean.config.dbplatform.DbDefaultValue; @@ -105,7 +105,7 @@ public class PlatformDdl { /** * Set configuration options. */ - public void configure(DatabaseConfig config) { + public void configure(DatabaseBuilder config) { historyDdl.configure(config, this); naming = config.getConstraintNaming(); } @@ -113,7 +113,7 @@ public class PlatformDdl { /** * Create a DdlHandler for the specific database platform. */ - public DdlHandler createDdlHandler(DatabaseConfig config) { + public DdlHandler createDdlHandler(DatabaseBuilder config) { return new BaseDdlHandler(config, this); } diff --git a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformHistoryDdl.java b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformHistoryDdl.java index dc027055e..41f62ec76 100644 --- a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformHistoryDdl.java +++ b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformHistoryDdl.java @@ -1,6 +1,6 @@ package io.ebeaninternal.dbmigration.ddlgeneration.platform; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; import io.ebeaninternal.dbmigration.ddlgeneration.DdlWrite; import io.ebeaninternal.dbmigration.migration.AddHistoryTable; import io.ebeaninternal.dbmigration.migration.DropHistoryTable; @@ -14,7 +14,7 @@ public interface PlatformHistoryDdl { /** * Configure typically reading the necessary parameters from DatabaseConfig and Platform. */ - void configure(DatabaseConfig config, PlatformDdl platformDdl); + void configure(DatabaseBuilder config, PlatformDdl platformDdl); /** * Creates a new table and add history support to the table using platform specific mechanism. @@ -33,7 +33,7 @@ public interface PlatformHistoryDdl { /** * Regenerate the history triggers/stored function due to column added/dropped/included or excluded. - * + * * Note: This function may be called multiple times for the same table. */ default void updateTriggers(DdlWrite writer, String tableName) { diff --git a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/SqlServerHistoryDdl.java b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/SqlServerHistoryDdl.java index 06aeff157..a0b1519cb 100644 --- a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/SqlServerHistoryDdl.java +++ b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/SqlServerHistoryDdl.java @@ -1,6 +1,6 @@ package io.ebeaninternal.dbmigration.ddlgeneration.platform; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; import io.ebean.config.DbConstraintNaming; import io.ebeaninternal.dbmigration.ddlgeneration.DdlAlterTable; import io.ebeaninternal.dbmigration.ddlgeneration.DdlBuffer; @@ -22,7 +22,7 @@ public class SqlServerHistoryDdl implements PlatformHistoryDdl { protected String historySuffix; @Override - public void configure(DatabaseConfig config, PlatformDdl platformDdl) { + public void configure(DatabaseBuilder config, PlatformDdl platformDdl) { this.systemPeriodStart = config.getAsOfSysPeriod() + "From"; this.systemPeriodEnd = config.getAsOfSysPeriod() + "To"; this.platformDdl = platformDdl; diff --git a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/model/PlatformDdlWriter.java b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/model/PlatformDdlWriter.java index 6f9e424a5..c0938701a 100644 --- a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/model/PlatformDdlWriter.java +++ b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/model/PlatformDdlWriter.java @@ -1,7 +1,7 @@ package io.ebeaninternal.dbmigration.model; import io.avaje.applog.AppLog; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; import io.ebean.config.dbplatform.DatabasePlatform; import io.ebean.util.IOUtils; import io.ebeaninternal.dbmigration.ddlgeneration.DdlHandler; @@ -26,13 +26,13 @@ public class PlatformDdlWriter { private static final System.Logger logger = AppLog.getLogger(PlatformDdlWriter.class); - private final DatabaseConfig databaseConfig; + private final DatabaseBuilder databaseBuilder; private final PlatformDdl platformDdl; private final int lockTimeoutSeconds; - public PlatformDdlWriter(DatabasePlatform platform, DatabaseConfig dbConfig, int lockTimeoutSeconds) { + public PlatformDdlWriter(DatabasePlatform platform, DatabaseBuilder dbConfig, int lockTimeoutSeconds) { this.platformDdl = PlatformDdlBuilder.create(platform); - this.databaseConfig = dbConfig; + this.databaseBuilder = dbConfig; this.lockTimeoutSeconds = lockTimeoutSeconds; } @@ -87,7 +87,7 @@ public class PlatformDdlWriter { * Write the 'Apply' DDL buffers to the writer. */ protected void writeApplyDdl(Writer writer, DdlWrite ddl) throws IOException { - String header = databaseConfig.getDdlHeader(); + String header = databaseBuilder.getDdlHeader(); if (header != null && !header.isEmpty()) { writer.append(header).append('\n'); } @@ -98,7 +98,7 @@ public class PlatformDdlWriter { * Return the platform specific DdlHandler (to generate DDL). */ protected DdlHandler handler() { - return platformDdl.createDdlHandler(databaseConfig); + return platformDdl.createDdlHandler(databaseBuilder); } /** diff --git a/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/BaseDdlHandlerTest.java b/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/BaseDdlHandlerTest.java index a0f376607..d90b1d14e 100644 --- a/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/BaseDdlHandlerTest.java +++ b/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/BaseDdlHandlerTest.java @@ -1,5 +1,6 @@ package io.ebeaninternal.dbmigration.ddlgeneration; +import io.ebean.DatabaseBuilder; import io.localtest.BaseTestCase; import io.ebean.DB; import io.ebean.config.DatabaseConfig; @@ -21,7 +22,7 @@ public class BaseDdlHandlerTest extends BaseTestCase { private static boolean useV1Syntax = Boolean.getBoolean("ebean.h2.useV1Syntax"); - private final DatabaseConfig serverConfig = new DatabaseConfig(); + private final DatabaseBuilder serverConfig = new DatabaseConfig(); private DdlHandler handler(DatabasePlatform platform) { return PlatformDdlBuilder.create(platform).createDdlHandler(serverConfig); diff --git a/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/BaseTableDdlTest.java b/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/BaseTableDdlTest.java index 921769dc4..dc63608af 100644 --- a/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/BaseTableDdlTest.java +++ b/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/BaseTableDdlTest.java @@ -1,5 +1,6 @@ package io.ebeaninternal.dbmigration.ddlgeneration.platform; +import io.ebean.DatabaseBuilder; import io.ebean.config.DatabaseConfig; import io.ebean.platform.clickhouse.ClickHousePlatform; import io.ebean.platform.h2.H2Platform; @@ -19,7 +20,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; class BaseTableDdlTest { - private final DatabaseConfig serverConfig = new DatabaseConfig(); + private final DatabaseBuilder serverConfig = new DatabaseConfig(); private final PlatformDdl h2ddl = PlatformDdlBuilder.create(new H2Platform()); @Test diff --git a/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl_AlterColumnTest.java b/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl_AlterColumnTest.java index 21c1320ab..733368700 100644 --- a/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl_AlterColumnTest.java +++ b/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl_AlterColumnTest.java @@ -1,7 +1,7 @@ package io.ebeaninternal.dbmigration.ddlgeneration.platform; import io.ebean.DB; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; import io.ebean.config.dbplatform.IdType; import io.ebean.platform.db2.DB2LuwPlatform; import io.ebean.platform.h2.H2Platform; @@ -36,7 +36,7 @@ public class PlatformDdl_AlterColumnTest { private final SoftAssertions softly = new SoftAssertions(); { - DatabaseConfig serverConfig = DB.getDefault().pluginApi().config(); + DatabaseBuilder serverConfig = DB.getDefault().pluginApi().config(); sqlServerDdl.configure(serverConfig); } diff --git a/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl_CreateIndexTest.java b/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl_CreateIndexTest.java index 871a065f1..9c7c55c7d 100644 --- a/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl_CreateIndexTest.java +++ b/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl_CreateIndexTest.java @@ -1,7 +1,7 @@ package io.ebeaninternal.dbmigration.ddlgeneration.platform; import io.ebean.DB; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; import io.ebean.platform.db2.DB2LuwPlatform; import io.ebean.platform.h2.H2Platform; import io.ebean.platform.hana.HanaPlatform; @@ -27,7 +27,7 @@ public class PlatformDdl_CreateIndexTest { private final PlatformDdl db2LuwDdl = PlatformDdlBuilder.create(new DB2LuwPlatform()); { - DatabaseConfig config = DB.getDefault().pluginApi().config(); + DatabaseBuilder config = DB.getDefault().pluginApi().config(); h2Ddl.configure(config); pgDdl.configure(config); mysqlDdl.configure(config); diff --git a/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl_dropUniqueConstraintTest.java b/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl_dropUniqueConstraintTest.java index bb9aca37d..35e012a5f 100644 --- a/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl_dropUniqueConstraintTest.java +++ b/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl_dropUniqueConstraintTest.java @@ -1,5 +1,6 @@ package io.ebeaninternal.dbmigration.ddlgeneration.platform; +import io.ebean.DatabaseBuilder; import io.ebean.config.DatabaseConfig; import io.ebean.platform.h2.H2Platform; import io.ebean.platform.hana.HanaPlatform; @@ -48,7 +49,7 @@ public class PlatformDdl_dropUniqueConstraintTest { sql = mysqlDdl.alterTableDropUniqueConstraint("mytab", "uq_name"); assertEquals("alter table mytab drop index uq_name", sql); - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); hanaDdl.configure(config); sql = hanaDdl.alterTableDropUniqueConstraint("mytab", "uq_name"); assertEquals("delimiter $$\n" + diff --git a/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/model/build/ModelBuildBeanVisitorTest.java b/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/model/build/ModelBuildBeanVisitorTest.java index 7be24c6f7..51fbf6605 100644 --- a/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/model/build/ModelBuildBeanVisitorTest.java +++ b/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/model/build/ModelBuildBeanVisitorTest.java @@ -1,6 +1,7 @@ package io.ebeaninternal.dbmigration.model.build; +import io.ebean.DatabaseBuilder; import io.localtest.BaseTestCase; import io.ebean.DB; import io.ebean.DatabaseFactory; @@ -54,7 +55,7 @@ public class ModelBuildBeanVisitorTest extends BaseTestCase { ModelContainer model = new ModelContainer(); - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); config.setName("h2"); config.loadFromProperties(); config.setName("h2other"); diff --git a/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/model/build/ModelBuild_compoundKeyTest.java b/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/model/build/ModelBuild_compoundKeyTest.java index d6bc51741..58a8f9062 100644 --- a/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/model/build/ModelBuild_compoundKeyTest.java +++ b/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/model/build/ModelBuild_compoundKeyTest.java @@ -1,6 +1,7 @@ package io.ebeaninternal.dbmigration.model.build; +import io.ebean.DatabaseBuilder; import io.localtest.BaseTestCase; import io.ebean.DatabaseFactory; import io.ebean.config.DatabaseConfig; @@ -25,7 +26,7 @@ public class ModelBuild_compoundKeyTest extends BaseTestCase { private SpiEbeanServer createServer() { - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); config.setName("h2"); config.loadFromProperties(); config.setName("h2other"); diff --git a/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/model/build/ModelBuild_compound_IdClassTest.java b/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/model/build/ModelBuild_compound_IdClassTest.java index 2c47bbaae..ce0429660 100644 --- a/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/model/build/ModelBuild_compound_IdClassTest.java +++ b/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/model/build/ModelBuild_compound_IdClassTest.java @@ -1,6 +1,7 @@ package io.ebeaninternal.dbmigration.model.build; +import io.ebean.DatabaseBuilder; import io.localtest.BaseTestCase; import io.ebean.DatabaseFactory; import io.ebean.config.DatabaseConfig; @@ -20,7 +21,7 @@ import static org.assertj.core.api.Assertions.assertThat; public class ModelBuild_compound_IdClassTest extends BaseTestCase { private SpiEbeanServer createServer() { - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); config.setName("h2"); config.loadFromProperties(); config.setName("h2other"); diff --git a/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/model/build/ModelBuild_explicitSequencesTest.java b/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/model/build/ModelBuild_explicitSequencesTest.java index 77f78452e..4e043b2bd 100644 --- a/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/model/build/ModelBuild_explicitSequencesTest.java +++ b/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/model/build/ModelBuild_explicitSequencesTest.java @@ -2,6 +2,7 @@ package io.ebeaninternal.dbmigration.model.build; import io.ebean.DatabaseFactory; +import io.ebean.DatabaseBuilder; import io.ebean.config.DatabaseConfig; import io.ebeaninternal.api.SpiEbeanServer; import io.ebeaninternal.dbmigration.ddlgeneration.DdlOptions; @@ -20,7 +21,7 @@ class ModelBuild_explicitSequencesTest extends BaseTestCase { private SpiEbeanServer createServer(boolean postgres) { - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); config.setName("h2"); config.loadFromProperties(); config.setName("h2other"); diff --git a/ebean-postgis-types/src/main/java/io/ebean/postgis/PostgisExtraTypeFactory.java b/ebean-postgis-types/src/main/java/io/ebean/postgis/PostgisExtraTypeFactory.java index c8c95e009..1630f968c 100644 --- a/ebean-postgis-types/src/main/java/io/ebean/postgis/PostgisExtraTypeFactory.java +++ b/ebean-postgis-types/src/main/java/io/ebean/postgis/PostgisExtraTypeFactory.java @@ -1,6 +1,6 @@ package io.ebean.postgis; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; import io.ebean.core.type.ExtraTypeFactory; import io.ebean.core.type.ScalarType; import io.ebean.postgis.latte.ScalarTypeGeoLatteLineString; @@ -16,7 +16,7 @@ import java.util.List; public class PostgisExtraTypeFactory implements ExtraTypeFactory { @Override - public List> createTypes(DatabaseConfig config, Object objectMapper) { + public List> createTypes(DatabaseBuilder config, Object objectMapper) { List> list = new ArrayList<>(); list.add(new ScalarTypePgisPoint()); diff --git a/ebean-postgis-types/src/main/java/io/ebean/postgis/PostgisGeoTypeBindProvider.java b/ebean-postgis-types/src/main/java/io/ebean/postgis/PostgisGeoTypeBindProvider.java index 7dd037e34..ab151db1d 100644 --- a/ebean-postgis-types/src/main/java/io/ebean/postgis/PostgisGeoTypeBindProvider.java +++ b/ebean-postgis-types/src/main/java/io/ebean/postgis/PostgisGeoTypeBindProvider.java @@ -1,13 +1,13 @@ package io.ebean.postgis; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; import io.ebeaninternal.api.GeoTypeProvider; import io.ebeaninternal.server.type.GeoTypeBinder; public class PostgisGeoTypeBindProvider implements GeoTypeProvider { @Override - public GeoTypeBinder createBinder(DatabaseConfig config) { + public GeoTypeBinder createBinder(DatabaseBuilder config) { boolean withGeolatte = config.getClassLoadConfig().isPresent("org.geolatte.geom.Geometry"); return new PostgisGeoTypeBinder(withGeolatte); } diff --git a/ebean-redis/src/main/java/io/ebean/redis/RedisCacheFactory.java b/ebean-redis/src/main/java/io/ebean/redis/RedisCacheFactory.java index 53d9ea926..6eda94bbd 100644 --- a/ebean-redis/src/main/java/io/ebean/redis/RedisCacheFactory.java +++ b/ebean-redis/src/main/java/io/ebean/redis/RedisCacheFactory.java @@ -3,7 +3,7 @@ package io.ebean.redis; import io.avaje.applog.AppLog; import io.ebean.BackgroundExecutor; import io.ebean.cache.*; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; import io.ebean.meta.MetricVisitor; import io.ebean.metric.MetricFactory; import io.ebean.metric.TimedMetric; @@ -74,7 +74,7 @@ final class RedisCacheFactory implements ServerCacheFactory { private final ReentrantLock lock = new ReentrantLock(); private ServerCacheNotify listener; - RedisCacheFactory(DatabaseConfig config, BackgroundExecutor executor) { + RedisCacheFactory(DatabaseBuilder config, BackgroundExecutor executor) { this.executor = executor; this.nearCacheNotify = new DNearCacheNotify(); MetricFactory factory = MetricFactory.get(); @@ -95,7 +95,7 @@ final class RedisCacheFactory implements ServerCacheFactory { /** * Return the JedisPool to use (only 1 at this stage). */ - private JedisPool getJedisPool(DatabaseConfig config) { + private JedisPool getJedisPool(DatabaseBuilder config) { JedisPool jedisPool = config.getServiceObject(JedisPool.class); if (jedisPool != null) { return jedisPool; diff --git a/ebean-redis/src/main/java/io/ebean/redis/RedisCachePlugin.java b/ebean-redis/src/main/java/io/ebean/redis/RedisCachePlugin.java index 27806a4c4..1edea4674 100644 --- a/ebean-redis/src/main/java/io/ebean/redis/RedisCachePlugin.java +++ b/ebean-redis/src/main/java/io/ebean/redis/RedisCachePlugin.java @@ -3,7 +3,7 @@ package io.ebean.redis; import io.ebean.BackgroundExecutor; import io.ebean.cache.ServerCacheFactory; import io.ebean.cache.ServerCachePlugin; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; public class RedisCachePlugin implements ServerCachePlugin { @@ -11,7 +11,7 @@ public class RedisCachePlugin implements ServerCachePlugin { * Create the ServerCacheFactory implementation. */ @Override - public ServerCacheFactory create(DatabaseConfig config, BackgroundExecutor executor) { + public ServerCacheFactory create(DatabaseBuilder config, BackgroundExecutor executor) { return new RedisCacheFactory(config, executor); } } diff --git a/ebean-redis/src/test/java/org/integration/ClusterTest.java b/ebean-redis/src/test/java/org/integration/ClusterTest.java index f52466c0b..8a8142706 100644 --- a/ebean-redis/src/test/java/org/integration/ClusterTest.java +++ b/ebean-redis/src/test/java/org/integration/ClusterTest.java @@ -1,5 +1,6 @@ package org.integration; +import io.ebean.DatabaseBuilder; import io.ebean.redis.DuelCache; import org.domain.Person; import io.ebean.DB; @@ -16,7 +17,7 @@ import static org.assertj.core.api.Assertions.assertThat; public class ClusterTest { private Database createOther(DataSource dataSource) { - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); config.setDataSource(dataSource); config.loadFromProperties(); config.setDefaultServer(false); diff --git a/ebean-spring-txn/src/test/java/org/example/EbeanServerFactoryBean.java b/ebean-spring-txn/src/test/java/org/example/EbeanServerFactoryBean.java index 935a2d224..db34c8827 100644 --- a/ebean-spring-txn/src/test/java/org/example/EbeanServerFactoryBean.java +++ b/ebean-spring-txn/src/test/java/org/example/EbeanServerFactoryBean.java @@ -3,7 +3,7 @@ package org.example; import io.ebean.Database; import io.ebean.DatabaseFactory; import io.ebean.annotation.PersistBatch; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.InitializingBean; @@ -18,7 +18,7 @@ public class EbeanServerFactoryBean implements InitializingBean, FactoryBean io.ebean ebean-joda-time - 13.18.0 + 13.24.0-RC1 test
io.ebean ebean-jackson-jsonnode - 13.18.0 + 13.24.0-RC1 test diff --git a/ebean-test/src/main/java/io/ebean/test/config/AutoConfigureForTesting.java b/ebean-test/src/main/java/io/ebean/test/config/AutoConfigureForTesting.java index 400dd921b..3ff4c5113 100644 --- a/ebean-test/src/main/java/io/ebean/test/config/AutoConfigureForTesting.java +++ b/ebean-test/src/main/java/io/ebean/test/config/AutoConfigureForTesting.java @@ -2,7 +2,7 @@ package io.ebean.test.config; import io.avaje.applog.AppLog; import io.ebean.config.AutoConfigure; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; import io.ebean.datasource.DataSourceBuilder; import io.ebean.test.config.platform.PlatformAutoConfig; import io.ebean.test.config.provider.ProviderAutoConfig; @@ -31,7 +31,7 @@ public class AutoConfigureForTesting implements AutoConfigure { private final String environmentDb = System.getProperty("db"); @Override - public void preConfigure(DatabaseConfig config) { + public void preConfigure(DatabaseBuilder config) { Properties properties = config.getProperties(); if (properties != null) { // trigger determination of docker.host system property if not already done @@ -55,7 +55,7 @@ public class AutoConfigureForTesting implements AutoConfigure { } @Override - public void postConfigure(DatabaseConfig config) { + public void postConfigure(DatabaseBuilder config) { if (!config.isDefaultServer()) { return; } @@ -87,7 +87,7 @@ public class AutoConfigureForTesting implements AutoConfigure { /** * Check if this is not the primary server and return true if that is the case. */ - private boolean isExtraServer(DatabaseConfig config, Properties properties) { + private boolean isExtraServer(DatabaseBuilder config, Properties properties) { String extraDb = properties.getProperty("ebean.test.extraDb.dbName", properties.getProperty("ebean.test.extraDb")); if (extraDb != null && extraDb.equals(config.getName())) { config.setDefaultServer(false); @@ -99,7 +99,7 @@ public class AutoConfigureForTesting implements AutoConfigure { /** * Setup the DataSource on the extra database if necessary. */ - private void setupExtraDataSourceIfNecessary(DatabaseConfig config) { + private void setupExtraDataSourceIfNecessary(DatabaseBuilder config) { DataSourceBuilder dataSourceConfig = config.getDataSourceConfig(); if (dataSourceConfig == null || dataSourceConfig.settings().getUsername() == null) { new PlatformAutoConfig(environmentDb, config) @@ -110,14 +110,14 @@ public class AutoConfigureForTesting implements AutoConfigure { /** * Setup support for Who, Multi-Tenant and DB encryption if they are not already set. */ - private void setupProviders(DatabaseConfig config) { + private void setupProviders(DatabaseBuilder config) { new ProviderAutoConfig(config).run(); } /** * Setup the platform for testing including docker as needed and adjusting datasource config as needed. */ - private void setupPlatform(String db, DatabaseConfig config) { + private void setupPlatform(String db, DatabaseBuilder config) { new PlatformAutoConfig(db, config).run(); } } diff --git a/ebean-test/src/main/java/io/ebean/test/config/platform/Config.java b/ebean-test/src/main/java/io/ebean/test/config/platform/Config.java index b5379830b..67feefc14 100644 --- a/ebean-test/src/main/java/io/ebean/test/config/platform/Config.java +++ b/ebean-test/src/main/java/io/ebean/test/config/platform/Config.java @@ -1,7 +1,7 @@ package io.ebean.test.config.platform; import io.avaje.applog.AppLog; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; import io.ebean.datasource.DataSourceConfig; import io.ebean.test.containers.DockerHost; @@ -37,11 +37,11 @@ class Config { private String schema; private String username; private String password; - private final DatabaseConfig config; + private final DatabaseBuilder config; private boolean containerDropCreate; private final Properties dockerProperties = new Properties(); - Config(String db, String platform, String databaseName, DatabaseConfig config) { + Config(String db, String platform, String databaseName, DatabaseBuilder config) { this.db = db; this.platform = platform; this.dockerPlatform = platform; diff --git a/ebean-test/src/main/java/io/ebean/test/config/platform/PlatformAutoConfig.java b/ebean-test/src/main/java/io/ebean/test/config/platform/PlatformAutoConfig.java index a986771ad..aa2d84710 100644 --- a/ebean-test/src/main/java/io/ebean/test/config/platform/PlatformAutoConfig.java +++ b/ebean-test/src/main/java/io/ebean/test/config/platform/PlatformAutoConfig.java @@ -1,7 +1,7 @@ package io.ebean.test.config.platform; import io.avaje.applog.AppLog; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; import io.ebean.test.containers.ContainerFactory; import java.util.HashMap; @@ -38,14 +38,14 @@ public class PlatformAutoConfig { KNOWN_PLATFORMS.put("yugabyte", new YugabyteSetup()); } - private final DatabaseConfig config; + private final DatabaseBuilder config; private final Properties properties; private String db; private String platform; private PlatformSetup platformSetup; private String databaseName; - public PlatformAutoConfig(String db, DatabaseConfig config) { + public PlatformAutoConfig(String db, DatabaseBuilder config) { this.db = db; this.config = config; this.properties = config.getProperties(); diff --git a/ebean-test/src/main/java/io/ebean/test/config/provider/ProviderAutoConfig.java b/ebean-test/src/main/java/io/ebean/test/config/provider/ProviderAutoConfig.java index a1b80b9da..c5658f229 100644 --- a/ebean-test/src/main/java/io/ebean/test/config/provider/ProviderAutoConfig.java +++ b/ebean-test/src/main/java/io/ebean/test/config/provider/ProviderAutoConfig.java @@ -1,10 +1,8 @@ package io.ebean.test.config.provider; import io.avaje.applog.AppLog; -import io.ebean.config.CurrentTenantProvider; -import io.ebean.config.CurrentUserProvider; -import io.ebean.config.DatabaseConfig; -import io.ebean.config.EncryptKeyManager; +import io.ebean.DatabaseBuilder; +import io.ebean.config.*; import java.util.Properties; @@ -18,10 +16,10 @@ public class ProviderAutoConfig { private static final System.Logger log = AppLog.getLogger("io.ebean.test"); - private final DatabaseConfig config; + private final DatabaseBuilder config; private final Properties properties; - public ProviderAutoConfig(DatabaseConfig config) { + public ProviderAutoConfig(DatabaseBuilder config) { this.config = config; this.properties = config.getProperties(); } diff --git a/ebean-test/src/test/java/io/ebean/test/config/platform/ConfigTest.java b/ebean-test/src/test/java/io/ebean/test/config/platform/ConfigTest.java index 2f0439c4a..168629694 100644 --- a/ebean-test/src/test/java/io/ebean/test/config/platform/ConfigTest.java +++ b/ebean-test/src/test/java/io/ebean/test/config/platform/ConfigTest.java @@ -1,6 +1,7 @@ package io.ebean.test.config.platform; import io.ebean.annotation.Platform; +import io.ebean.DatabaseBuilder; import io.ebean.config.DatabaseConfig; import io.ebean.datasource.DataSourceBuilder; import io.ebeaninternal.api.DbOffline; @@ -37,10 +38,10 @@ class ConfigTest { @Test void extensions_whenNoSetValues() { - DatabaseConfig databaseConfig = new DatabaseConfig(); - databaseConfig.loadFromProperties(new Properties()); + DatabaseBuilder databaseBuilder = new DatabaseConfig(); + databaseBuilder.loadFromProperties(new Properties()); - Config config = new Config("db", "postgis", "db", databaseConfig); + Config config = new Config("db", "postgis", "db", databaseBuilder); config.setUsernameDefault(); config.setPasswordDefault(); @@ -55,13 +56,13 @@ class ConfigTest { @Test void extensions_whenSetValues() { - DatabaseConfig databaseConfig = new DatabaseConfig(); + DatabaseBuilder databaseBuilder = new DatabaseConfig(); Properties properties = new Properties(); properties.setProperty("ebean.test.extensions", "x,y"); properties.setProperty("ebean.test.extraDb.extensions", "z"); - databaseConfig.loadFromProperties(properties); + databaseBuilder.loadFromProperties(properties); - Config config = new Config("db", "postgis", "db", databaseConfig); + Config config = new Config("db", "postgis", "db", databaseBuilder); config.setExtensions("a,b"); config.setExtraExtensions("c,d"); @@ -77,7 +78,7 @@ class ConfigTest { Properties p = new Properties(); p.setProperty("ebean.test.extraDb", "other"); - DatabaseConfig serverConfig = new DatabaseConfig(); + DatabaseBuilder serverConfig = new DatabaseConfig(); serverConfig.loadFromProperties(p); Config config = new Config("other", "postgres", "other", serverConfig); @@ -99,7 +100,7 @@ class ConfigTest { Properties p = new Properties(); p.setProperty("ebean.test.extraDb.dbName", "other"); - DatabaseConfig serverConfig = new DatabaseConfig(); + DatabaseBuilder serverConfig = new DatabaseConfig(); serverConfig.loadFromProperties(p); Config config = new Config("other", "postgres", "other", serverConfig); @@ -125,7 +126,7 @@ class ConfigTest { p.setProperty("ebean.test.extraDb.password", "other_pwd"); p.setProperty("ebean.test.extraDb.url", "other_url"); - DatabaseConfig serverConfig = new DatabaseConfig(); + DatabaseBuilder serverConfig = new DatabaseConfig(); serverConfig.setName("scOther"); serverConfig.loadFromProperties(p); @@ -150,7 +151,7 @@ class ConfigTest { sourceProperties.setProperty("ebean.test.dbName", "main"); sourceProperties.setProperty("ebean.test.extraDb.dbName", "central"); - DatabaseConfig serverConfig = new DatabaseConfig(); + DatabaseBuilder serverConfig = new DatabaseConfig(); serverConfig.setName("main"); serverConfig.loadFromProperties(sourceProperties); @@ -163,7 +164,7 @@ class ConfigTest { assertThat(mainProps.getProperty("datasource.main.username")).isEqualTo("main"); - DatabaseConfig centralConfig = new DatabaseConfig(); + DatabaseBuilder centralConfig = new DatabaseConfig(); centralConfig.setName("central"); centralConfig.loadFromProperties(sourceProperties); @@ -219,7 +220,7 @@ class ConfigTest { } private Config createConfig(Properties p) { - DatabaseConfig serverConfig = new DatabaseConfig(); + DatabaseBuilder serverConfig = new DatabaseConfig(); serverConfig.setName("scOther"); serverConfig.loadFromProperties(p); return new Config("db_name", "postgres", "db_name", serverConfig); diff --git a/ebean-test/src/test/java/io/ebean/xtest/base/EbeanServerFactory_MultiTenancy_Test.java b/ebean-test/src/test/java/io/ebean/xtest/base/EbeanServerFactory_MultiTenancy_Test.java index 0dcc4afc2..3b5c54f35 100644 --- a/ebean-test/src/test/java/io/ebean/xtest/base/EbeanServerFactory_MultiTenancy_Test.java +++ b/ebean-test/src/test/java/io/ebean/xtest/base/EbeanServerFactory_MultiTenancy_Test.java @@ -1,5 +1,6 @@ package io.ebean.xtest.base; +import io.ebean.DatabaseBuilder; import io.ebean.xtest.BaseTestCase; import io.ebean.Database; import io.ebean.DatabaseFactory; @@ -27,7 +28,7 @@ public class EbeanServerFactory_MultiTenancy_Test extends BaseTestCase { TenantDataSourceProvider dataSourceProvider = Mockito.mock(TenantDataSourceProvider.class); Mockito.doReturn(mockedDataSource).when(dataSourceProvider).dataSource(tenant); - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); config.setName("multiTenantDb"); config.loadFromProperties(); config.setRegister(false); @@ -62,7 +63,7 @@ public class EbeanServerFactory_MultiTenancy_Test extends BaseTestCase { TenantSchemaProvider schemaProvider = Mockito.mock(TenantSchemaProvider.class); Mockito.doReturn("tenant_schema").when(schemaProvider).schema(tenant); - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); config.setName("h2"); config.loadFromProperties(); config.setName("multi-tenancy"); @@ -93,7 +94,7 @@ public class EbeanServerFactory_MultiTenancy_Test extends BaseTestCase { TenantCatalogProvider catalogProvider = Mockito.mock(TenantCatalogProvider.class); Mockito.doReturn("tenant_catalog").when(catalogProvider).catalog(tenant); - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); config.setName("h2"); config.loadFromProperties(); config.setName("multi-tenancy"); diff --git a/ebean-test/src/test/java/io/ebean/xtest/base/EbeanServerFactory_ServerConfigStart_Test.java b/ebean-test/src/test/java/io/ebean/xtest/base/EbeanServerFactory_ServerConfigStart_Test.java index 841a552fa..46e532b06 100644 --- a/ebean-test/src/test/java/io/ebean/xtest/base/EbeanServerFactory_ServerConfigStart_Test.java +++ b/ebean-test/src/test/java/io/ebean/xtest/base/EbeanServerFactory_ServerConfigStart_Test.java @@ -2,6 +2,7 @@ package io.ebean.xtest.base; import io.ebean.Database; import io.ebean.DatabaseFactory; +import io.ebean.DatabaseBuilder; import io.ebean.config.DatabaseConfig; import io.ebean.event.ServerConfigStartup; import io.ebeaninternal.api.SpiLogger; @@ -45,7 +46,7 @@ public class EbeanServerFactory_ServerConfigStart_Test { @Test public void test() throws InterruptedException { - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); config.setName("h2"); config.loadFromProperties(); config.setName("h2other"); @@ -82,10 +83,10 @@ public class EbeanServerFactory_ServerConfigStart_Test { public static class OnStartup implements ServerConfigStartup { - DatabaseConfig calledWithConfig; + DatabaseBuilder calledWithConfig; @Override - public void onStart(DatabaseConfig serverConfig) { + public void onStart(DatabaseBuilder serverConfig) { calledWithConfig = serverConfig; } } @@ -93,10 +94,10 @@ public class EbeanServerFactory_ServerConfigStart_Test { public static class OnStartupViaClass implements ServerConfigStartup { - static DatabaseConfig calledWithConfig; + static DatabaseBuilder calledWithConfig; @Override - public void onStart(DatabaseConfig serverConfig) { + public void onStart(DatabaseBuilder serverConfig) { calledWithConfig = serverConfig; } } diff --git a/ebean-test/src/test/java/io/ebean/xtest/config/DbMigrationConfigTest.java b/ebean-test/src/test/java/io/ebean/xtest/config/DbMigrationConfigTest.java index dfbdb2291..06b885191 100644 --- a/ebean-test/src/test/java/io/ebean/xtest/config/DbMigrationConfigTest.java +++ b/ebean-test/src/test/java/io/ebean/xtest/config/DbMigrationConfigTest.java @@ -1,5 +1,6 @@ package io.ebean.xtest.config; +import io.ebean.DatabaseBuilder; import io.ebean.config.DatabaseConfig; import io.ebean.migration.MigrationConfig; import org.junit.jupiter.api.Test; @@ -15,7 +16,7 @@ public class DbMigrationConfigTest { @Test public void testLoad() { - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); config.setName("h2other"); config.loadFromProperties(); config.setDefaultServer(false); diff --git a/ebean-test/src/test/java/io/ebean/xtest/config/PlatformNoGeneratedKeysTest.java b/ebean-test/src/test/java/io/ebean/xtest/config/PlatformNoGeneratedKeysTest.java index 2d29618ec..34afc8256 100644 --- a/ebean-test/src/test/java/io/ebean/xtest/config/PlatformNoGeneratedKeysTest.java +++ b/ebean-test/src/test/java/io/ebean/xtest/config/PlatformNoGeneratedKeysTest.java @@ -4,6 +4,7 @@ import io.ebean.Database; import io.ebean.DatabaseFactory; import io.ebean.Transaction; import io.ebean.annotation.Platform; +import io.ebean.DatabaseBuilder; import io.ebean.config.DatabaseConfig; import io.ebean.config.dbplatform.DbIdentity; import io.ebean.config.dbplatform.IdType; @@ -88,7 +89,7 @@ public class PlatformNoGeneratedKeysTest { private static Database testH2Server() { - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); config.setName("h2_noGeneratedKeys"); OtherH2Platform platform = new OtherH2Platform(); diff --git a/ebean-test/src/test/java/io/ebean/xtest/config/ServerConfigSqlServerTest.java b/ebean-test/src/test/java/io/ebean/xtest/config/ServerConfigSqlServerTest.java index 47e2fd94d..6dc2f6dba 100644 --- a/ebean-test/src/test/java/io/ebean/xtest/config/ServerConfigSqlServerTest.java +++ b/ebean-test/src/test/java/io/ebean/xtest/config/ServerConfigSqlServerTest.java @@ -4,6 +4,7 @@ package io.ebean.xtest.config; import io.ebean.Database; import io.ebean.DatabaseFactory; import io.ebean.annotation.Platform; +import io.ebean.DatabaseBuilder; import io.ebean.config.DatabaseConfig; import io.ebean.xtest.ForPlatform; import org.junit.jupiter.api.Disabled; @@ -26,7 +27,7 @@ public class ServerConfigSqlServerTest { // no explicit databasePlatformName set .. //props.setProperty("ebean.some_sqlserver.databasePlatformName", "sqlserver17"); - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); config.setName("some_sqlserver"); config.loadFromProperties(props); @@ -61,7 +62,7 @@ public class ServerConfigSqlServerTest { String name = "testsqlserver17"; - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); config.setName(name); Properties props = props(name); @@ -94,7 +95,7 @@ public class ServerConfigSqlServerTest { Properties props = props(name); //props.setProperty("ebean.testsqlserver16.databasePlatformName", "sqlserver16"); - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); config.setDefaultServer(false); config.setRegister(false); config.setDdlGenerate(true); diff --git a/ebean-test/src/test/java/io/ebean/xtest/dbmigration/DbMigrationDropHistoryTest.java b/ebean-test/src/test/java/io/ebean/xtest/dbmigration/DbMigrationDropHistoryTest.java index 4f5471c62..f1657ca27 100644 --- a/ebean-test/src/test/java/io/ebean/xtest/dbmigration/DbMigrationDropHistoryTest.java +++ b/ebean-test/src/test/java/io/ebean/xtest/dbmigration/DbMigrationDropHistoryTest.java @@ -2,6 +2,7 @@ package io.ebean.xtest.dbmigration; import io.ebean.Database; import io.ebean.DatabaseFactory; +import io.ebean.DatabaseBuilder; import io.ebean.config.DatabaseConfig; import io.ebean.dbmigration.DbMigration; import org.junit.jupiter.api.Test; @@ -46,7 +47,7 @@ class DbMigrationDropHistoryTest { migration.setPathToResources("src/test/resources"); - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); config.setName("migrationtest-history"); config.loadFromProperties(); config.setRegister(false); diff --git a/ebean-test/src/test/java/io/ebean/xtest/dbmigration/DbMigrationGenerateTest.java b/ebean-test/src/test/java/io/ebean/xtest/dbmigration/DbMigrationGenerateTest.java index df7074216..8b387a8da 100644 --- a/ebean-test/src/test/java/io/ebean/xtest/dbmigration/DbMigrationGenerateTest.java +++ b/ebean-test/src/test/java/io/ebean/xtest/dbmigration/DbMigrationGenerateTest.java @@ -3,6 +3,7 @@ package io.ebean.xtest.dbmigration; import io.ebean.Database; import io.ebean.DatabaseFactory; import io.ebean.annotation.Platform; +import io.ebean.DatabaseBuilder; import io.ebean.config.DatabaseConfig; import io.ebean.dbmigration.DbMigration; import org.junit.jupiter.api.Test; @@ -88,7 +89,7 @@ public class DbMigrationGenerateTest { migration.addPlatform(Platform.YUGABYTE); - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); config.setName("migrationtest"); config.loadFromProperties(); config.setRegister(false); diff --git a/ebean-test/src/test/java/io/ebean/xtest/dbmigration/DbMigrationTest.java b/ebean-test/src/test/java/io/ebean/xtest/dbmigration/DbMigrationTest.java index 2f7585c93..6671d4bc5 100644 --- a/ebean-test/src/test/java/io/ebean/xtest/dbmigration/DbMigrationTest.java +++ b/ebean-test/src/test/java/io/ebean/xtest/dbmigration/DbMigrationTest.java @@ -2,6 +2,7 @@ package io.ebean.xtest.dbmigration; import io.ebean.*; import io.ebean.annotation.Platform; +import io.ebean.DatabaseBuilder; import io.ebean.config.DatabaseConfig; import io.ebean.config.dbplatform.DbHistorySupport; import io.ebean.datasource.DataSourcePool; @@ -215,7 +216,7 @@ public class DbMigrationTest extends BaseTestCase { if (history == null) { return; } - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); config.setName(server().name()); config.loadFromProperties(server().pluginApi().config().getProperties()); config.setDataSource(server().dataSource()); @@ -287,7 +288,7 @@ public class DbMigrationTest extends BaseTestCase { // do some history tests with V1.1 models private void testReservedKeywords() { - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); config.setName(server().name()); config.loadFromProperties(server().pluginApi().config().getProperties()); config.setDataSource(server().dataSource()); diff --git a/ebean-test/src/test/java/io/ebean/xtest/event/BeanFindControllerTest.java b/ebean-test/src/test/java/io/ebean/xtest/event/BeanFindControllerTest.java index 43e207d8e..8032a4f7e 100644 --- a/ebean-test/src/test/java/io/ebean/xtest/event/BeanFindControllerTest.java +++ b/ebean-test/src/test/java/io/ebean/xtest/event/BeanFindControllerTest.java @@ -4,6 +4,7 @@ import io.ebean.Database; import io.ebean.DatabaseFactory; import io.ebean.bean.BeanCollection; import io.ebean.common.BeanList; +import io.ebean.DatabaseBuilder; import io.ebean.config.DatabaseConfig; import io.ebean.event.BeanFindController; import io.ebean.event.BeanQueryRequest; @@ -26,7 +27,7 @@ public class BeanFindControllerTest extends BaseTestCase { @Test public void test() { - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); config.setName("h2otherfind"); config.loadFromProperties(); @@ -169,7 +170,7 @@ public class BeanFindControllerTest extends BaseTestCase { } private Database prepareSoftRefs() { - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); config.setName("h2otherfind"); config.loadFromProperties(); diff --git a/ebean-test/src/test/java/io/ebean/xtest/event/BeanPersistControllerTest.java b/ebean-test/src/test/java/io/ebean/xtest/event/BeanPersistControllerTest.java index 65695a7b0..e89b808a9 100644 --- a/ebean-test/src/test/java/io/ebean/xtest/event/BeanPersistControllerTest.java +++ b/ebean-test/src/test/java/io/ebean/xtest/event/BeanPersistControllerTest.java @@ -4,6 +4,7 @@ package io.ebean.xtest.event; import io.ebean.Database; import io.ebean.DatabaseFactory; import io.ebean.Transaction; +import io.ebean.DatabaseBuilder; import io.ebean.config.DatabaseConfig; import io.ebean.event.BeanDeleteIdRequest; import io.ebean.event.BeanPersistAdapter; @@ -140,7 +141,7 @@ public class BeanPersistControllerTest { } private Database getDatabase(PersistAdapter persistAdapter) { - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); config.setName("h2ebasicver"); config.loadFromProperties(); config.setDdlGenerate(true); diff --git a/ebean-test/src/test/java/io/ebean/xtest/event/BeanPostLoadTest.java b/ebean-test/src/test/java/io/ebean/xtest/event/BeanPostLoadTest.java index f08a4e7b5..fbc6ac0b3 100644 --- a/ebean-test/src/test/java/io/ebean/xtest/event/BeanPostLoadTest.java +++ b/ebean-test/src/test/java/io/ebean/xtest/event/BeanPostLoadTest.java @@ -5,6 +5,7 @@ import io.ebean.BeanState; import io.ebean.DB; import io.ebean.Database; import io.ebean.DatabaseFactory; +import io.ebean.DatabaseBuilder; import io.ebean.config.DatabaseConfig; import io.ebean.event.BeanPostLoad; import io.ebean.xtest.BaseTestCase; @@ -48,7 +49,7 @@ public class BeanPostLoadTest extends BaseTestCase { private Database createDatabase() { - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); config.setName("h2ebasicver"); config.loadFromProperties(); diff --git a/ebean-test/src/test/java/io/ebean/xtest/internal/api/TDSpiEbeanServer.java b/ebean-test/src/test/java/io/ebean/xtest/internal/api/TDSpiEbeanServer.java index 1e0610335..c44de8899 100644 --- a/ebean-test/src/test/java/io/ebean/xtest/internal/api/TDSpiEbeanServer.java +++ b/ebean-test/src/test/java/io/ebean/xtest/internal/api/TDSpiEbeanServer.java @@ -7,7 +7,7 @@ import io.ebean.annotation.TxIsolation; import io.ebean.bean.BeanCollection; import io.ebean.bean.CallOrigin; import io.ebean.cache.ServerCacheManager; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; import io.ebean.config.dbplatform.DatabasePlatform; import io.ebean.event.readaudit.ReadAuditLogger; import io.ebean.event.readaudit.ReadAuditPrepare; @@ -126,7 +126,7 @@ public class TDSpiEbeanServer extends TDSpiServer implements SpiEbeanServer { } @Override - public DatabaseConfig config() { + public DatabaseBuilder config() { return null; } diff --git a/ebean-test/src/test/java/io/ebean/xtest/internal/api/TDSpiServer.java b/ebean-test/src/test/java/io/ebean/xtest/internal/api/TDSpiServer.java index 4229e5e42..301b2aa0f 100644 --- a/ebean-test/src/test/java/io/ebean/xtest/internal/api/TDSpiServer.java +++ b/ebean-test/src/test/java/io/ebean/xtest/internal/api/TDSpiServer.java @@ -7,7 +7,7 @@ import io.ebean.annotation.TxIsolation; import io.ebean.bean.BeanLoader; import io.ebean.bean.EntityBeanIntercept; import io.ebean.cache.ServerCacheManager; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; import io.ebean.config.dbplatform.DatabasePlatform; import io.ebean.meta.MetaInfoManager; import io.ebean.plugin.BeanType; @@ -579,7 +579,7 @@ public class TDSpiServer implements SpiServer { } @Override - public DatabaseConfig config() { + public DatabaseBuilder config() { return null; } diff --git a/ebean-test/src/test/java/io/ebean/xtest/internal/server/text/json/DJsonScalarTest.java b/ebean-test/src/test/java/io/ebean/xtest/internal/server/text/json/DJsonScalarTest.java index 9f2ed2c8c..295bdcd4b 100644 --- a/ebean-test/src/test/java/io/ebean/xtest/internal/server/text/json/DJsonScalarTest.java +++ b/ebean-test/src/test/java/io/ebean/xtest/internal/server/text/json/DJsonScalarTest.java @@ -2,6 +2,7 @@ package io.ebean.xtest.internal.server.text.json; import com.fasterxml.jackson.core.JsonFactory; import com.fasterxml.jackson.core.JsonGenerator; +import io.ebean.DatabaseBuilder; import io.ebean.config.DatabaseConfig; import io.ebean.platform.h2.H2Platform; import io.ebeaninternal.server.core.bootup.BootupClasses; @@ -23,7 +24,7 @@ public class DJsonScalarTest { private final DJsonScalar jsonScalar; public DJsonScalarTest() { - DatabaseConfig serverConfig = new DatabaseConfig(); + DatabaseBuilder serverConfig = new DatabaseConfig(); serverConfig.setDatabasePlatform(new H2Platform()); DefaultTypeManager typeManager = new DefaultTypeManager(serverConfig, new BootupClasses()); jsonScalar = new DJsonScalar(typeManager); diff --git a/ebean-test/src/test/java/io/ebean/xtest/internal/server/transaction/DefaultTransactionThreadLocalTest.java b/ebean-test/src/test/java/io/ebean/xtest/internal/server/transaction/DefaultTransactionThreadLocalTest.java index 4af273919..8c9455bcb 100644 --- a/ebean-test/src/test/java/io/ebean/xtest/internal/server/transaction/DefaultTransactionThreadLocalTest.java +++ b/ebean-test/src/test/java/io/ebean/xtest/internal/server/transaction/DefaultTransactionThreadLocalTest.java @@ -5,6 +5,7 @@ import io.ebean.Database; import io.ebean.DatabaseFactory; import io.ebean.Transaction; import io.ebean.annotation.Platform; +import io.ebean.DatabaseBuilder; import io.ebean.config.DatabaseConfig; import io.ebean.xtest.BaseTestCase; import io.ebean.xtest.ForPlatform; @@ -133,7 +134,7 @@ public class DefaultTransactionThreadLocalTest extends BaseTestCase { private Database createOtherDatabase() { - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); config.setName("h2ebasicver"); config.loadFromProperties(); config.setDdlGenerate(true); diff --git a/ebean-test/src/test/java/org/multitenant/partition/MultiTenantPartitionTest.java b/ebean-test/src/test/java/org/multitenant/partition/MultiTenantPartitionTest.java index 90dc62e44..2f976f5b0 100644 --- a/ebean-test/src/test/java/org/multitenant/partition/MultiTenantPartitionTest.java +++ b/ebean-test/src/test/java/org/multitenant/partition/MultiTenantPartitionTest.java @@ -2,6 +2,7 @@ package org.multitenant.partition; import io.ebean.Database; import io.ebean.DatabaseFactory; +import io.ebean.DatabaseBuilder; import io.ebean.config.DatabaseConfig; import io.ebean.config.TenantMode; import io.ebean.test.LoggedSql; @@ -119,7 +120,7 @@ class MultiTenantPartitionTest extends BaseTestCase { } private static Database init() { - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); config.setName("h2multitenant"); config.loadFromProperties(); config.setDdlGenerate(true); diff --git a/ebean-test/src/test/java/org/tests/basic/MainDbBoolean.java b/ebean-test/src/test/java/org/tests/basic/MainDbBoolean.java index 31cbbfd0a..ddb240ad4 100644 --- a/ebean-test/src/test/java/org/tests/basic/MainDbBoolean.java +++ b/ebean-test/src/test/java/org/tests/basic/MainDbBoolean.java @@ -4,6 +4,7 @@ import io.ebean.Database; import io.ebean.DatabaseFactory; import io.ebean.Query; import io.ebean.SqlRow; +import io.ebean.DatabaseBuilder; import io.ebean.config.DatabaseConfig; import io.ebean.platform.postgres.PostgresPlatform; import io.ebean.datasource.DataSourceConfig; @@ -37,7 +38,7 @@ public class MainDbBoolean { * DDL generation etc. */ private Database createOracleEbeanServer() { - DatabaseConfig c = new DatabaseConfig(); + DatabaseBuilder c = new DatabaseConfig(); c.setName("ora"); c.setDdlExtra(false); @@ -70,7 +71,7 @@ public class MainDbBoolean { } private Database createEbeanServer() { - DatabaseConfig c = new DatabaseConfig(); + DatabaseBuilder c = new DatabaseConfig(); c.setName("pgtest"); c.setDdlExtra(false); diff --git a/ebean-test/src/test/java/org/tests/basic/TestPersistenceContext.java b/ebean-test/src/test/java/org/tests/basic/TestPersistenceContext.java index 4a36fb268..cc18f4a95 100644 --- a/ebean-test/src/test/java/org/tests/basic/TestPersistenceContext.java +++ b/ebean-test/src/test/java/org/tests/basic/TestPersistenceContext.java @@ -4,6 +4,7 @@ import io.ebean.DB; import io.ebean.DatabaseFactory; import io.ebean.QueryIterator; import io.ebean.Transaction; +import io.ebean.DatabaseBuilder; import io.ebean.config.DatabaseConfig; import io.ebean.xtest.BaseTestCase; import io.ebeaninternal.api.SpiPersistenceContext; @@ -257,7 +258,7 @@ public class TestPersistenceContext extends BaseTestCase { @Test @Disabled void initDb() { - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); config.setName("h2-batch"); config.loadFromProperties(); config.setDdlExtra(false); @@ -291,7 +292,7 @@ public class TestPersistenceContext extends BaseTestCase { @Test @Disabled void testFindEachFindList() { - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); config.setName("h2-batch"); config.loadFromProperties(); config.setDdlRun(false); diff --git a/ebean-test/src/test/java/org/tests/basic/TestPersistenceContextMany.java b/ebean-test/src/test/java/org/tests/basic/TestPersistenceContextMany.java index 6a2d78454..8fd251873 100644 --- a/ebean-test/src/test/java/org/tests/basic/TestPersistenceContextMany.java +++ b/ebean-test/src/test/java/org/tests/basic/TestPersistenceContextMany.java @@ -3,6 +3,7 @@ package org.tests.basic; import io.ebean.DB; import io.ebean.DatabaseFactory; import io.ebean.QueryIterator; +import io.ebean.DatabaseBuilder; import io.ebean.config.DatabaseConfig; import io.ebean.xtest.BaseTestCase; import org.junit.jupiter.api.Disabled; @@ -97,7 +98,7 @@ public class TestPersistenceContextMany extends BaseTestCase { @Test @Disabled void initDb() { - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); config.setName("h2-batch"); config.loadFromProperties(); config.setDdlExtra(false); @@ -141,7 +142,7 @@ public class TestPersistenceContextMany extends BaseTestCase { @Test @Disabled void testFindEachFindList() { - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); config.setName("h2-batch"); config.loadFromProperties(); config.setDdlRun(false); diff --git a/ebean-test/src/test/java/org/tests/cache/TestBeanCacheAsync.java b/ebean-test/src/test/java/org/tests/cache/TestBeanCacheAsync.java index 15b25cd85..912617236 100644 --- a/ebean-test/src/test/java/org/tests/cache/TestBeanCacheAsync.java +++ b/ebean-test/src/test/java/org/tests/cache/TestBeanCacheAsync.java @@ -1,13 +1,11 @@ package org.tests.cache; +import io.ebean.DatabaseBuilder; +import io.ebean.config.*; import io.ebean.xtest.BaseTestCase; import io.ebean.DB; import io.ebean.Database; import io.ebean.DatabaseFactory; -import io.ebean.config.BackgroundExecutorWrapper; -import io.ebean.config.CurrentTenantProvider; -import io.ebean.config.DatabaseConfig; -import io.ebean.config.MdcBackgroundExecutorWrapper; import io.ebeaninternal.server.cache.DefaultServerCachePlugin; import org.junit.jupiter.api.Test; import org.tests.model.basic.OCachedBean; @@ -65,7 +63,7 @@ public class TestBeanCacheAsync extends BaseTestCase { @Test public void findById_with_tenant() throws InterruptedException { - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); config.setName(DB.getDefault().name()); config.loadFromProperties(); config.setDataSource(DB.getDefault().dataSource()); diff --git a/ebean-test/src/test/java/org/tests/changelog/TestChangeLog.java b/ebean-test/src/test/java/org/tests/changelog/TestChangeLog.java index 2145b38d6..4946a1334 100644 --- a/ebean-test/src/test/java/org/tests/changelog/TestChangeLog.java +++ b/ebean-test/src/test/java/org/tests/changelog/TestChangeLog.java @@ -2,6 +2,7 @@ package org.tests.changelog; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.ObjectMapper; +import io.ebean.DatabaseBuilder; import io.ebean.xtest.BaseTestCase; import io.ebean.Database; import io.ebean.DatabaseFactory; @@ -171,7 +172,7 @@ public class TestChangeLog extends BaseTestCase { private Database createServer() { - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); config.setName("h2other"); config.loadFromProperties(); config.setDdlGenerate(true); diff --git a/ebean-test/src/test/java/org/tests/json/TestJsonSourceDefault.java b/ebean-test/src/test/java/org/tests/json/TestJsonSourceDefault.java index 201c00220..daaa7c70e 100644 --- a/ebean-test/src/test/java/org/tests/json/TestJsonSourceDefault.java +++ b/ebean-test/src/test/java/org/tests/json/TestJsonSourceDefault.java @@ -3,6 +3,7 @@ package org.tests.json; import io.ebean.Database; import io.ebean.DatabaseFactory; import io.ebean.ValuePair; +import io.ebean.DatabaseBuilder; import io.ebean.xtest.ForPlatform; import io.ebean.annotation.MutationDetection; import io.ebean.annotation.Platform; @@ -22,7 +23,7 @@ class TestJsonSourceDefault { @ForPlatform(Platform.H2) @Disabled void testDirtyValues_diffSource() { - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); config.getDataSourceConfig() .setUsername("sa") .setPassword("") diff --git a/ebean-test/src/test/java/org/tests/model/basic/MyEBasicConfigStartup.java b/ebean-test/src/test/java/org/tests/model/basic/MyEBasicConfigStartup.java index 71ea07436..14eeed9d3 100644 --- a/ebean-test/src/test/java/org/tests/model/basic/MyEBasicConfigStartup.java +++ b/ebean-test/src/test/java/org/tests/model/basic/MyEBasicConfigStartup.java @@ -1,6 +1,6 @@ package org.tests.model.basic; -import io.ebean.config.DatabaseConfig; +import io.ebean.DatabaseBuilder; import io.ebean.event.AbstractBeanPersistListener; import io.ebean.event.BulkTableEvent; import io.ebean.event.BulkTableEventListener; @@ -23,7 +23,7 @@ public class MyEBasicConfigStartup implements ServerConfigStartup { } @Override - public void onStart(DatabaseConfig serverConfig) { + public void onStart(DatabaseBuilder serverConfig) { serverConfig.add(new EbasicPersistList()); serverConfig.add(new EbasicBulkListener()); diff --git a/ebean-test/src/test/java/org/tests/persistencecontext/TestPersistenceContextServerConfig.java b/ebean-test/src/test/java/org/tests/persistencecontext/TestPersistenceContextServerConfig.java index b066c01a2..fc515d2fe 100644 --- a/ebean-test/src/test/java/org/tests/persistencecontext/TestPersistenceContextServerConfig.java +++ b/ebean-test/src/test/java/org/tests/persistencecontext/TestPersistenceContextServerConfig.java @@ -2,6 +2,7 @@ package org.tests.persistencecontext; import io.ebean.*; import io.ebean.config.ContainerConfig; +import io.ebean.DatabaseBuilder; import io.ebean.config.DatabaseConfig; import io.ebean.xtest.BaseTestCase; import io.ebeaninternal.api.SpiEbeanServer; @@ -30,7 +31,7 @@ public class TestPersistenceContextServerConfig extends BaseTestCase { static Database create() { - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); config.setName("withPCQuery"); config.setDdlExtra(false); diff --git a/ebean-test/src/test/java/org/tests/readaudit/TestReadAudit.java b/ebean-test/src/test/java/org/tests/readaudit/TestReadAudit.java index 3cf98812d..b1bb498d9 100644 --- a/ebean-test/src/test/java/org/tests/readaudit/TestReadAudit.java +++ b/ebean-test/src/test/java/org/tests/readaudit/TestReadAudit.java @@ -1,5 +1,6 @@ package org.tests.readaudit; +import io.ebean.DatabaseBuilder; import io.ebean.xtest.BaseTestCase; import io.ebean.Database; import io.ebean.DatabaseFactory; @@ -302,7 +303,7 @@ public class TestReadAudit extends BaseTestCase { private Database createServer() { - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); config.setName("h2other"); config.loadFromProperties(); diff --git a/ebean-test/src/test/java/org/tests/timezone/LocalTimeTest.java b/ebean-test/src/test/java/org/tests/timezone/LocalTimeTest.java index 6f5b7e0f9..5ad4c8ce2 100644 --- a/ebean-test/src/test/java/org/tests/timezone/LocalTimeTest.java +++ b/ebean-test/src/test/java/org/tests/timezone/LocalTimeTest.java @@ -2,6 +2,7 @@ package org.tests.timezone; import io.ebean.Database; import io.ebean.DatabaseFactory; +import io.ebean.DatabaseBuilder; import io.ebean.config.DatabaseConfig; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; @@ -52,7 +53,7 @@ public class LocalTimeTest { } private Database createServer(String dbTimeZone) { - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); config.setName(platform); config.loadFromProperties(); config.setDdlExtra(false); diff --git a/ebean-test/src/test/java/org/tests/unitinternal/HelloMain.java b/ebean-test/src/test/java/org/tests/unitinternal/HelloMain.java index d679d31a6..6b7909940 100644 --- a/ebean-test/src/test/java/org/tests/unitinternal/HelloMain.java +++ b/ebean-test/src/test/java/org/tests/unitinternal/HelloMain.java @@ -2,6 +2,7 @@ package org.tests.unitinternal; import io.ebean.Database; import io.ebean.DatabaseFactory; +import io.ebean.DatabaseBuilder; import io.ebean.config.DatabaseConfig; import io.ebean.datasource.DataSourceConfig; import org.slf4j.Logger; @@ -16,7 +17,7 @@ public class HelloMain { public static void main(String[] args) { // ### Configuration Objects ### - DatabaseConfig serverConfig = new DatabaseConfig(); + DatabaseBuilder serverConfig = new DatabaseConfig(); DataSourceConfig dataSourceConfig = new DataSourceConfig(); // ### Configuration Settings ### diff --git a/platforms/sqlserver/src/test/java/io/ebean/platform/sqlserver/SqlServerPlatformTest.java b/platforms/sqlserver/src/test/java/io/ebean/platform/sqlserver/SqlServerPlatformTest.java index 75c844962..7277c226b 100644 --- a/platforms/sqlserver/src/test/java/io/ebean/platform/sqlserver/SqlServerPlatformTest.java +++ b/platforms/sqlserver/src/test/java/io/ebean/platform/sqlserver/SqlServerPlatformTest.java @@ -1,5 +1,6 @@ package io.ebean.platform.sqlserver; +import io.ebean.DatabaseBuilder; import io.ebean.config.*; import io.ebean.config.dbplatform.*; import org.junit.jupiter.api.Test; @@ -11,7 +12,7 @@ class SqlServerPlatformTest { @Test public void convertQuotedIdentifiers_when_allQuotedIdentifier_sqlServer() { - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); config.setAllQuotedIdentifiers(true); config.setNamingConvention(new MatchingNamingConvention()); @@ -25,7 +26,7 @@ class SqlServerPlatformTest { @Test public void convertQuotedIdentifiers() { - DatabaseConfig config = new DatabaseConfig(); + DatabaseBuilder config = new DatabaseConfig(); SqlServer17Platform dbPlatform = new SqlServer17Platform(); dbPlatform.configure(config.getPlatformConfig()); diff --git a/tests/test-java16/pom.xml b/tests/test-java16/pom.xml index a77dc4940..b3063904d 100644 --- a/tests/test-java16/pom.xml +++ b/tests/test-java16/pom.xml @@ -17,7 +17,7 @@ io.ebean - ebean + ebean-h2 13.23.2-jakarta From 1f9cf1e4b7d13911f1a2d3c01e41afe77cc47c78 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Fri, 3 Nov 2023 22:58:11 +1300 Subject: [PATCH 2/6] Split DatabaseBuilder interface separating the setters n getters adding DatabaseBuilder.Settings So DatabaseBuilder.Settings has all the getters for code looking to read the configuration that has been set. So DatabaseBuilder now just has the setter methods. Use DatabaseBuilder.settings() to access the settings and read the config that has been set. --- composites/ebean/pom.xml | 4 +- .../main/java/io/ebean/DatabaseBuilder.java | 1695 +++++++++-------- .../main/java/io/ebean/DatabaseFactory.java | 5 +- .../java/io/ebean/config/DatabaseConfig.java | 7 +- .../main/java/io/ebean/plugin/SpiServer.java | 2 +- .../io/ebean/config/DatabaseConfigTest.java | 83 +- ebean-bom/pom.xml | 4 +- .../io/ebean/core/type/ExtraTypeFactory.java | 2 +- .../ebean/core/type/ScalarTypeSetFactory.java | 2 +- .../io/ebeaninternal/api/GeoTypeProvider.java | 2 +- .../server/cache/CacheManagerOptions.java | 4 +- .../server/core/ClassPathScanners.java | 2 +- .../server/core/DatabasePlatformFactory.java | 2 +- .../server/core/DefaultContainer.java | 22 +- .../server/core/DefaultServer.java | 6 +- .../server/core/InitDataSource.java | 6 +- .../server/core/InternalConfiguration.java | 10 +- .../core/bootup/BootupClassPathSearch.java | 4 +- .../server/core/bootup/BootupClasses.java | 2 +- .../server/deploy/BeanDescriptor.java | 2 +- .../server/deploy/BeanDescriptorManager.java | 12 +- .../server/deploy/BeanDescriptorMap.java | 2 +- .../deploy/BeanLifecycleAdapterFactory.java | 2 +- .../GeneratedPropertyFactory.java | 2 +- .../deploy/meta/DeployBeanDescriptor.java | 4 +- .../server/deploy/parse/DeployUtil.java | 2 +- .../deploy/parse/ReadAnnotationConfig.java | 2 +- .../server/deploy/parse/ReadAnnotations.java | 2 +- .../server/query/CQueryEngine.java | 2 +- .../TransactionManagerOptions.java | 6 +- .../server/type/DefaultTypeFactory.java | 4 +- .../server/type/DefaultTypeManager.java | 14 +- .../server/core/InitDataSourceTest.java | 36 +- .../deploy/parse/AnnotationClassTest.java | 6 +- .../server/type/DefaultTypeFactoryTest.java | 3 +- .../server/type/DefaultTypeManagerTest.java | 2 +- .../server/type/TestTypeManager.java | 4 +- .../dbmigration/DdlGenerator.java | 4 +- .../dbmigration/DefaultDbMigration.java | 5 +- .../io/ebeaninternal/dbmigration/Detect.java | 2 +- .../ddlgeneration/BaseDdlHandler.java | 2 +- .../ddlgeneration/platform/BaseTableDdl.java | 2 +- .../ddlgeneration/platform/ClickHouseDdl.java | 2 +- .../platform/ClickHouseDdlHandler.java | 2 +- .../platform/ClickHouseTableDdl.java | 2 +- .../ddlgeneration/platform/Db2HistoryDdl.java | 2 +- .../platform/DbTableBasedHistoryDdl.java | 2 +- .../platform/DbTriggerBasedHistoryDdl.java | 2 +- .../platform/HanaHistoryDdl.java | 2 +- .../platform/MariaDbHistoryDdl.java | 2 +- .../platform/NoHistorySupportDdl.java | 2 +- .../ddlgeneration/platform/PlatformDdl.java | 4 +- .../platform/PlatformHistoryDdl.java | 2 +- .../platform/SqlServerHistoryDdl.java | 2 +- .../dbmigration/model/PlatformDdlWriter.java | 10 +- .../ddlgeneration/BaseDdlHandlerTest.java | 2 +- .../platform/BaseTableDdlTest.java | 2 +- .../platform/PlatformDdl_AlterColumnTest.java | 2 +- .../platform/PlatformDdl_CreateIndexTest.java | 3 +- .../PlatformDdl_dropUniqueConstraintTest.java | 2 +- .../build/ModelBuildBeanVisitorTest.java | 2 +- .../postgis/PostgisExtraTypeFactory.java | 2 +- .../postgis/PostgisGeoTypeBindProvider.java | 2 +- .../io/ebean/redis/RedisCacheFactory.java | 4 +- .../java/io/ebean/redis/RedisCachePlugin.java | 2 +- ebean-test/pom.xml | 4 +- .../test/config/AutoConfigureForTesting.java | 14 +- .../io/ebean/test/config/platform/Config.java | 4 +- .../config/platform/PlatformAutoConfig.java | 4 +- .../config/provider/ProviderAutoConfig.java | 4 +- .../test/config/platform/ConfigTest.java | 14 +- .../xtest/config/DbMigrationConfigTest.java | 2 +- .../config/PlatformNoGeneratedKeysTest.java | 2 +- .../dbmigration/DbMigrationGenerateTest.java | 2 +- .../xtest/event/BeanFindControllerTest.java | 4 +- .../xtest/internal/api/TDSpiEbeanServer.java | 2 +- .../ebean/xtest/internal/api/TDSpiServer.java | 2 +- .../server/text/json/DJsonScalarTest.java | 2 +- .../tests/basic/TestPersistenceContext.java | 4 +- .../basic/TestPersistenceContextMany.java | 4 +- .../org/tests/json/TestJsonSourceDefault.java | 2 +- .../sqlserver/SqlServerPlatformTest.java | 4 +- 82 files changed, 1074 insertions(+), 1045 deletions(-) diff --git a/composites/ebean/pom.xml b/composites/ebean/pom.xml index 6cee65e1e..5eb91bd26 100644 --- a/composites/ebean/pom.xml +++ b/composites/ebean/pom.xml @@ -29,13 +29,13 @@ io.ebean ebean-joda-time - 13.24.0-RC1 + 13.24.0-RC2 io.ebean ebean-jackson-jsonnode - 13.24.0-RC1 + 13.24.0-RC2 diff --git a/ebean-api/src/main/java/io/ebean/DatabaseBuilder.java b/ebean-api/src/main/java/io/ebean/DatabaseBuilder.java index 1ecced869..cf70dd01e 100644 --- a/ebean-api/src/main/java/io/ebean/DatabaseBuilder.java +++ b/ebean-api/src/main/java/io/ebean/DatabaseBuilder.java @@ -26,31 +26,19 @@ import java.util.*; import java.util.function.Function; public interface DatabaseBuilder { - /** - * Get the clock used for setting the timestamps (e.g. @UpdatedTimestamp) on objects. - */ - Clock getClock(); + + Settings settings(); /** * Set the clock used for setting the timestamps (e.g. @UpdatedTimestamp) on objects. */ void setClock(Clock clock); - /** - * Return the slow query time in millis. - */ - long getSlowQueryMillis(); - /** * Set the slow query time in millis. */ void setSlowQueryMillis(long slowQueryMillis); - /** - * Return the slow query event listener. - */ - SlowQueryListener getSlowQueryListener(); - /** * Set the slow query event listener. */ @@ -78,11 +66,6 @@ public interface DatabaseBuilder { */ void putServiceObject(Class iface, T configObject); - /** - * Return the service object given the key. - */ - Object getServiceObject(String key); - /** * Put a service object into configuration such that it can be used by ebean or a plugin. * @@ -105,28 +88,6 @@ public interface DatabaseBuilder { return Character.toLowerCase(simpleName.charAt(0)) + simpleName.substring(1); } - /** - * Used by ebean or plugins to obtain service objects. - * - *
{@code
-   *
-   *   JedisPool jedisPool = config.getServiceObject(JedisPool.class);
-   *
-   * }
- * - * @param cls The type of the service object to obtain - * @return The service object given the class type - */ - @SuppressWarnings("unchecked") -

P getServiceObject(Class

cls); - - /** - * Return the Jackson JsonFactory to use. - *

- * If not set a default implementation will be used. - */ - JsonFactory getJsonFactory(); - /** * Set the Jackson JsonFactory to use. *

@@ -134,31 +95,16 @@ public interface DatabaseBuilder { */ void setJsonFactory(JsonFactory jsonFactory); - /** - * Return the JSON format used for DateTime types. - */ - JsonConfig.DateTime getJsonDateTime(); - /** * Set the JSON format to use for DateTime types. */ void setJsonDateTime(JsonConfig.DateTime jsonDateTime); - /** - * Return the JSON format used for Date types. - */ - JsonConfig.Date getJsonDate(); - /** * Set the JSON format to use for Date types. */ void setJsonDate(JsonConfig.Date jsonDate); - /** - * Return the JSON include mode used when writing JSON. - */ - JsonConfig.Include getJsonInclude(); - /** * Set the JSON include mode used when writing JSON. *

@@ -166,13 +112,6 @@ public interface DatabaseBuilder { */ void setJsonInclude(JsonConfig.Include jsonInclude); - /** - * Return the default MutableDetection to use with {@code @DbJson} using Jackson. - * - * @see DbJson#mutationDetection() - */ - MutationDetection getJsonMutationDetection(); - /** * Set the default MutableDetection to use with {@code @DbJson} using Jackson. * @@ -180,23 +119,11 @@ public interface DatabaseBuilder { */ void setJsonMutationDetection(MutationDetection jsonMutationDetection); - /** - * Return the name of the Database. - */ - String getName(); - /** * Set the name of the Database. */ void setName(String name); - /** - * Return the container / clustering configuration. - *

- * The container holds all the Database instances and provides clustering communication - * services to all the Database instances. - */ - ContainerConfig getContainerConfig(); /** * Set the container / clustering configuration. @@ -206,14 +133,6 @@ public interface DatabaseBuilder { */ void setContainerConfig(ContainerConfig containerConfig); - /** - * Return true if this server should be registered with the Ebean singleton - * when it is created. - *

- * By default this is set to true. - */ - boolean isRegister(); - /** * Set to false if you do not want this server to be registered with the Ebean * singleton when it is created. @@ -222,14 +141,6 @@ public interface DatabaseBuilder { */ void setRegister(boolean register); - /** - * Return true if this server should be registered as the "default" server - * with the Ebean singleton. - *

- * This is only used when {@link #setRegister(boolean)} is also true. - */ - boolean isDefaultServer(); - /** * Set false if you do not want this Database to be registered as the "default" database * with the DB singleton. @@ -238,63 +149,32 @@ public interface DatabaseBuilder { */ void setDefaultServer(boolean defaultServer); - /** - * Return the CurrentUserProvider. This is used to populate @WhoCreated, @WhoModified and - * support other audit features (who executed a query etc). - */ - CurrentUserProvider getCurrentUserProvider(); - /** * Set the CurrentUserProvider. This is used to populate @WhoCreated, @WhoModified and * support other audit features (who executed a query etc). */ void setCurrentUserProvider(CurrentUserProvider currentUserProvider); - /** - * Return the tenancy mode used. - */ - TenantMode getTenantMode(); - /** * Set the tenancy mode to use. */ void setTenantMode(TenantMode tenantMode); - /** - * Return the column name used for TenantMode.PARTITION. - */ - String getTenantPartitionColumn(); - /** * Set the column name used for TenantMode.PARTITION. */ void setTenantPartitionColumn(String tenantPartitionColumn); - /** - * Return the current tenant provider. - */ - CurrentTenantProvider getCurrentTenantProvider(); - /** * Set the current tenant provider. */ void setCurrentTenantProvider(CurrentTenantProvider currentTenantProvider); - /** - * Return the tenancy datasource provider. - */ - TenantDataSourceProvider getTenantDataSourceProvider(); - /** * Set the tenancy datasource provider. */ void setTenantDataSourceProvider(TenantDataSourceProvider tenantDataSourceProvider); - /** - * Return the tenancy schema provider. - */ - TenantSchemaProvider getTenantSchemaProvider(); - /** * Set the tenancy schema provider. */ @@ -320,15 +200,6 @@ public interface DatabaseBuilder { */ void setAutoPersistUpdates(boolean autoPersistUpdates); - /** - * Return the PersistBatch mode to use by default 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. - */ - PersistBatch getPersistBatch(); - /** * Set the JDBC batch mode to use at the transaction level. *

@@ -338,16 +209,6 @@ public interface DatabaseBuilder { */ void setPersistBatch(PersistBatch persistBatch); - /** - * Return the JDBC batch mode to use per save(), delete(), insert() or update() request. - *

- * This makes sense when a save() or delete() cascades and executes multiple child statements. The best case - * 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. - */ - PersistBatch getPersistBatchOnCascade(); - /** * Set the JDBC batch mode to use per save(), delete(), insert() or update() request. *

@@ -371,11 +232,6 @@ public interface DatabaseBuilder { */ void setPersistBatching(boolean persistBatching); - /** - * Return the batch size used for JDBC batching. This defaults to 20. - */ - int getPersistBatchSize(); - /** * Set the batch size used for JDBC batching. If unset this defaults to 20. *

@@ -385,13 +241,6 @@ public interface DatabaseBuilder { */ void setPersistBatchSize(int persistBatchSize); - /** - * Gets the query batch size. This defaults to 100. - * - * @return the query batch size - */ - int getQueryBatchSize(); - /** * Sets the query batch size. This defaults to 100. * @@ -399,15 +248,8 @@ public interface DatabaseBuilder { */ void setQueryBatchSize(int queryBatchSize); - EnumType getDefaultEnumType(); - void setDefaultEnumType(EnumType defaultEnumType); - /** - * Return true if lazy loading is disabled on queries by default. - */ - boolean isDisableLazyLoading(); - /** * Set to true to disable lazy loading by default. *

@@ -415,11 +257,6 @@ public interface DatabaseBuilder { */ void setDisableLazyLoading(boolean disableLazyLoading); - /** - * Return the default batch size for lazy loading of beans and collections. - */ - int getLazyLoadBatchSize(); - /** * Set the default batch size for lazy loading. *

@@ -442,34 +279,16 @@ public interface DatabaseBuilder { */ void setDatabaseSequenceBatchSize(int databaseSequenceBatchSize); - /** - * Return the default JDBC fetchSize hint for findList queries. - */ - int getJdbcFetchSizeFindList(); - /** * Set the default JDBC fetchSize hint for findList queries. */ void setJdbcFetchSizeFindList(int jdbcFetchSizeFindList); - /** - * Return the default JDBC fetchSize hint for findEach/findEachWhile queries. - */ - int getJdbcFetchSizeFindEach(); - /** * Set the default JDBC fetchSize hint for findEach/findEachWhile queries. */ void setJdbcFetchSizeFindEach(int jdbcFetchSizeFindEach); - /** - * Return the ChangeLogPrepare. - *

- * This is used to set user context information to the ChangeSet in the - * foreground thread prior to the logging occurring in a background thread. - */ - ChangeLogPrepare getChangeLogPrepare(); - /** * Set the ChangeLogPrepare. *

@@ -478,25 +297,12 @@ public interface DatabaseBuilder { */ void setChangeLogPrepare(ChangeLogPrepare changeLogPrepare); - /** - * Return the ChangeLogListener which actually performs the logging of change sets - * in the background. - */ - ChangeLogListener getChangeLogListener(); - /** * Set the ChangeLogListener which actually performs the logging of change sets * in the background. */ void setChangeLogListener(ChangeLogListener changeLogListener); - /** - * Return 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. - */ - ChangeLogRegister getChangeLogRegister(); - /** * 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 @@ -504,31 +310,16 @@ public interface DatabaseBuilder { */ void setChangeLogRegister(ChangeLogRegister changeLogRegister); - /** - * Return true if inserts should be included in the change log by default. - */ - boolean isChangeLogIncludeInserts(); - /** * Set if inserts should be included in the change log by default. */ void setChangeLogIncludeInserts(boolean changeLogIncludeInserts); - /** - * Return true (default) if the changelog should be written async. - */ - boolean isChangeLogAsync(); - /** * Sets if the changelog should be written async (default = true). */ void setChangeLogAsync(boolean changeLogAsync); - /** - * Return the ReadAuditLogger to use. - */ - ReadAuditLogger getReadAuditLogger(); - /** * 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 @@ -536,11 +327,6 @@ public interface DatabaseBuilder { */ void setReadAuditLogger(ReadAuditLogger readAuditLogger); - /** - * Return the ReadAuditPrepare to use. - */ - ReadAuditPrepare getReadAuditPrepare(); - /** * Set the ReadAuditPrepare to use. *

@@ -550,21 +336,11 @@ public interface DatabaseBuilder { */ void setReadAuditPrepare(ReadAuditPrepare readAuditPrepare); - /** - * Return the configuration for profiling. - */ - ProfilingConfig getProfilingConfig(); - /** * Set the configuration for profiling. */ void setProfilingConfig(ProfilingConfig profilingConfig); - /** - * Return the DB schema to use. - */ - String getDbSchema(); - /** * Set the DB schema to use. This specifies to use this schema for: *

    @@ -575,223 +351,110 @@ public interface DatabaseBuilder { */ void setDbSchema(String dbSchema); - /** - * Return the Geometry SRID. - */ - int getGeometrySRID(); - /** * Set the Geometry SRID. */ void setGeometrySRID(int geometrySRID); - /** - * Return the time zone to use when reading/writing Timestamps via JDBC. - *

    - * When set a Calendar object is used in JDBC calls when reading/writing Timestamp objects. - */ - String getDataTimeZone(); - /** * Set the time zone to use when reading/writing Timestamps via JDBC. */ void setDataTimeZone(String dataTimeZone); - /** - * Return 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. - */ - String getAsOfViewSuffix(); - /** * 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); - /** - * Return the database column used to support history and 'As of' queries. This column is a timestamp range - * or equivalent. - */ - String getAsOfSysPeriod(); - /** * Set the database column used to support history and 'As of' queries. This column is a timestamp range * or equivalent. */ void setAsOfSysPeriod(String asOfSysPeriod); - /** - * Return the history table suffix (defaults to _history). - */ - String getHistoryTableSuffix(); - /** * Set the history table suffix. */ void setHistoryTableSuffix(String historyTableSuffix); - /** - * Return true if we are running in a JTA Transaction manager. - */ - boolean isUseJtaTransactionManager(); - /** * Set to true if we are running in a JTA Transaction manager. */ void setUseJtaTransactionManager(boolean useJtaTransactionManager); - /** - * Return the external transaction manager. - */ - ExternalTransactionManager getExternalTransactionManager(); - /** * Set the external transaction manager. */ void setExternalTransactionManager(ExternalTransactionManager externalTransactionManager); - /** - * Return the ServerCachePlugin. - */ - ServerCachePlugin getServerCachePlugin(); - /** * Set the ServerCachePlugin to use. */ void setServerCachePlugin(ServerCachePlugin serverCachePlugin); - /** - * Return true if LOB's should default to fetch eager. - * By default this is set to false and LOB's must be explicitly fetched. - */ - boolean isEagerFetchLobs(); - /** * 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); - /** - * Return the max call stack to use for origin location. - */ - int getMaxCallStack(); - /** * Set the max call stack to use for origin location. */ void setMaxCallStack(int maxCallStack); - /** - * Return true if transactions should rollback on checked exceptions. - */ - boolean isTransactionRollbackOnChecked(); - /** * Set to true if transactions should by default rollback on checked exceptions. */ void setTransactionRollbackOnChecked(boolean transactionRollbackOnChecked); - /** - * Return the Background executor schedule pool size. Defaults to 1. - */ - int getBackgroundExecutorSchedulePoolSize(); - /** * Set the Background executor schedule pool size. */ void setBackgroundExecutorSchedulePoolSize(int backgroundExecutorSchedulePoolSize); - /** - * Return the Background executor shutdown seconds. This is the time allowed for the pool to shutdown nicely - * before it is forced shutdown. - */ - int getBackgroundExecutorShutdownSecs(); - /** * 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); - /** - * Return the background executor wrapper. - */ - BackgroundExecutorWrapper getBackgroundExecutorWrapper(); - /** * 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); - /** - * Return the L2 cache default max size. - */ - int getCacheMaxSize(); - /** * Set the L2 cache default max size. */ void setCacheMaxSize(int cacheMaxSize); - /** - * Return the L2 cache default max idle time in seconds. - */ - int getCacheMaxIdleTime(); - /** * Set the L2 cache default max idle time in seconds. */ void setCacheMaxIdleTime(int cacheMaxIdleTime); - /** - * Return the L2 cache default max time to live in seconds. - */ - int getCacheMaxTimeToLive(); - /** * Set the L2 cache default max time to live in seconds. */ void setCacheMaxTimeToLive(int cacheMaxTimeToLive); - /** - * Return the L2 query cache default max size. - */ - int getQueryCacheMaxSize(); - /** * Set the L2 query cache default max size. */ void setQueryCacheMaxSize(int queryCacheMaxSize); - /** - * Return the L2 query cache default max idle time in seconds. - */ - int getQueryCacheMaxIdleTime(); - /** * Set the L2 query cache default max idle time in seconds. */ void setQueryCacheMaxIdleTime(int queryCacheMaxIdleTime); - /** - * Return the L2 query cache default max time to live in seconds. - */ - int getQueryCacheMaxTimeToLive(); - /** * Set the L2 query cache default max time to live in seconds. */ void setQueryCacheMaxTimeToLive(int queryCacheMaxTimeToLive); - /** - * Return the NamingConvention. - *

    - * If none has been set the default UnderscoreNamingConvention is used. - */ - NamingConvention getNamingConvention(); - /** * Set the NamingConvention. *

    @@ -799,11 +462,6 @@ public interface DatabaseBuilder { */ void setNamingConvention(NamingConvention namingConvention); - /** - * Return true if all DB column and table names should use quoted identifiers. - */ - boolean isAllQuotedIdentifiers(); - /** * Set to true if all DB column and table names should use quoted identifiers. *

    @@ -812,71 +470,36 @@ public interface DatabaseBuilder { */ void setAllQuotedIdentifiers(boolean allQuotedIdentifiers); - /** - * Return true if this Database is a Document store only instance (has no JDBC DB). - */ - boolean isDocStoreOnly(); - /** * Set to true if this Database is Document store only instance (has no JDBC DB). */ void setDocStoreOnly(boolean docStoreOnly); - /** - * Return the configuration for the ElasticSearch integration. - */ - DocStoreConfig getDocStoreConfig(); - /** * Set the configuration for the ElasticSearch integration. */ void setDocStoreConfig(DocStoreConfig docStoreConfig); - /** - * Return the constraint naming convention used in DDL generation. - */ - DbConstraintNaming getConstraintNaming(); - /** * Set the constraint naming convention used in DDL generation. */ void setConstraintNaming(DbConstraintNaming constraintNaming); - /** - * Return the configuration for AutoTune. - */ - AutoTuneConfig getAutoTuneConfig(); - /** * Set the configuration for AutoTune. */ void setAutoTuneConfig(AutoTuneConfig autoTuneConfig); - /** - * Return true if the startup DataSource check should be skipped. - */ - boolean skipDataSourceCheck(); - /** * Set to true to skip the startup DataSource check. */ void setSkipDataSourceCheck(boolean skipDataSourceCheck); - /** - * Return the DataSource. - */ - DataSource getDataSource(); - /** * Set a DataSource. */ void setDataSource(DataSource dataSource); - /** - * Return the read only DataSource. - */ - DataSource getReadOnlyDataSource(); - /** * Set the read only DataSource. *

    @@ -888,53 +511,22 @@ public interface DatabaseBuilder { */ void setReadOnlyDataSource(DataSource readOnlyDataSource); - /** - * Return the configuration to build a DataSource using Ebean's own DataSource - * implementation. - */ - DataSourceBuilder getDataSourceConfig(); - /** * Set the configuration required to build a DataSource using Ebean's own * DataSource implementation. */ void setDataSourceConfig(DataSourceBuilder dataSourceConfig); - /** - * Return true if Ebean should create a DataSource for use with implicit read only transactions. - */ - boolean isAutoReadOnlyDataSource(); - /** * Set to true if Ebean should create a DataSource for use with implicit read only transactions. */ void setAutoReadOnlyDataSource(boolean autoReadOnlyDataSource); - /** - * Return the configuration for the read only DataSource. - *

    - * This is only used if autoReadOnlyDataSource is true. - *

    - * The driver, url, username and password default to the configuration for the main DataSource if they are not - * set on this configuration. This means there is actually no need to set any configuration here and we only - * set configuration for url, username and password etc if it is different from the main DataSource. - */ - DataSourceBuilder getReadOnlyDataSourceConfig(); - /** * Set the configuration for the read only DataSource. */ void setReadOnlyDataSourceConfig(DataSourceBuilder readOnlyDataSourceConfig); - /** - * Return a value used to represent TRUE in the database. - *

    - * This is used for databases that do not support boolean natively. - *

    - * The value returned is either a Integer or a String (e.g. "1", or "T"). - */ - String getDatabaseBooleanTrue(); - /** * Set the value to represent TRUE in the database. *

    @@ -944,15 +536,6 @@ public interface DatabaseBuilder { */ void setDatabaseBooleanTrue(String databaseTrue); - /** - * Return a value used to represent FALSE in the database. - *

    - * This is used for databases that do not support boolean natively. - *

    - * The value returned is either a Integer or a String (e.g. "0", or "F"). - */ - String getDatabaseBooleanFalse(); - /** * Set the value to represent FALSE in the database. *

    @@ -962,11 +545,6 @@ public interface DatabaseBuilder { */ void setDatabaseBooleanFalse(String databaseFalse); - /** - * Return the number of DB sequence values that should be preallocated. - */ - int getDatabaseSequenceBatchSize(); - /** * Set the number of DB sequence values that should be preallocated and cached * by Ebean. @@ -982,14 +560,6 @@ public interface DatabaseBuilder { */ void setDatabaseSequenceBatch(int databaseSequenceBatchSize); - /** - * Return the database platform name (can be null). - *

    - * If null then the platform is determined automatically via the JDBC driver - * information. - */ - String getDatabasePlatformName(); - /** * Explicitly set the database platform name *

    @@ -1005,11 +575,6 @@ public interface DatabaseBuilder { */ void setDatabasePlatformName(String databasePlatformName); - /** - * Return the database platform to use for this database. - */ - DatabasePlatform getDatabasePlatform(); - /** * Explicitly set the database platform to use. *

    @@ -1018,21 +583,11 @@ public interface DatabaseBuilder { */ void setDatabasePlatform(DatabasePlatform databasePlatform); - /** - * Return the preferred DB platform IdType. - */ - IdType getIdType(); - /** * Set the preferred DB platform IdType. */ void setIdType(IdType idType); - /** - * Return the EncryptKeyManager. - */ - EncryptKeyManager getEncryptKeyManager(); - /** * Set the EncryptKeyManager. *

    @@ -1047,14 +602,6 @@ public interface DatabaseBuilder { */ void setEncryptKeyManager(EncryptKeyManager encryptKeyManager); - /** - * Return the EncryptDeployManager. - *

    - * This is optionally used to programmatically define which columns are - * encrypted instead of using the {@link Encrypted} Annotation. - */ - EncryptDeployManager getEncryptDeployManager(); - /** * Set the EncryptDeployManager. *

    @@ -1063,12 +610,6 @@ public interface DatabaseBuilder { */ void setEncryptDeployManager(EncryptDeployManager encryptDeployManager); - /** - * Return the Encryptor used to encrypt data on the java client side (as - * opposed to DB encryption functions). - */ - Encryptor getEncryptor(); - /** * Set the Encryptor used to encrypt data on the java client side (as opposed * to DB encryption functions). @@ -1078,11 +619,6 @@ public interface DatabaseBuilder { */ void setEncryptor(Encryptor encryptor); - /** - * Return true if the Database instance should be created in offline mode. - */ - boolean isDbOffline(); - /** * Set to true if the Database instance should be created in offline mode. *

    @@ -1091,14 +627,6 @@ public interface DatabaseBuilder { */ void setDbOffline(boolean dbOffline); - /** - * Return the DbEncrypt used to encrypt and decrypt properties. - *

    - * Note that if this is not set then the DbPlatform may already have a - * DbEncrypt set and that will be used. - */ - DbEncrypt getDbEncrypt(); - /** * Set the DbEncrypt used to encrypt and decrypt properties. *

    @@ -1107,56 +635,32 @@ public interface DatabaseBuilder { */ void setDbEncrypt(DbEncrypt dbEncrypt); - /** - * Return the configuration for DB types (such as UUID and custom mappings). - */ - PlatformConfig getPlatformConfig(); - /** * Set the configuration for DB platform (such as UUID and custom mappings). */ void setPlatformConfig(PlatformConfig platformConfig); + /** * Set the DB type used to store UUID. */ void setDbUuid(PlatformConfig.DbUuid dbUuid); - /** - * Returns the UUID version mode. - */ - DatabaseConfig.UuidVersion getUuidVersion(); - /** * Sets the UUID version mode. */ void setUuidVersion(DatabaseConfig.UuidVersion uuidVersion); - /** - * Return the UUID state file. - */ - String getUuidStateFile(); - /** * Set the UUID state file. */ void setUuidStateFile(String uuidStateFile); - /** - * Returns the V1-UUID-NodeId - */ - String getUuidNodeId(); - /** * Sets the V1-UUID-NodeId. */ void setUuidNodeId(String uuidNodeId); - /** - * Return true if LocalTime should be persisted with nanos precision. - */ - boolean isLocalTimeWithNanos(); - /** * Set to true if LocalTime should be persisted with nanos precision. *

    @@ -1164,13 +668,6 @@ public interface DatabaseBuilder { */ void setLocalTimeWithNanos(boolean localTimeWithNanos); - /** - * Return true if Duration should be persisted with nanos precision (SQL DECIMAL). - *

    - * Otherwise it is persisted with second precision (SQL INTEGER). - */ - boolean isDurationWithNanos(); - /** * Set to true if Duration should be persisted with nanos precision (SQL DECIMAL). *

    @@ -1186,11 +683,6 @@ public interface DatabaseBuilder { */ void setRunMigration(boolean runMigration); - /** - * Return true if the DB migration should run on server start. - */ - boolean isRunMigration(); - /** * Set to true to generate the "create all" DDL on startup. *

    @@ -1214,14 +706,6 @@ public interface DatabaseBuilder { */ void setDdlExtra(boolean ddlExtra); - /** - * Return true if the "drop all ddl" should be skipped. - *

    - * 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. - */ - boolean isDdlCreateOnly(); - /** * Set to true if the "drop all ddl" should be skipped. *

    @@ -1230,14 +714,6 @@ public interface DatabaseBuilder { */ void setDdlCreateOnly(boolean ddlCreateOnly); - /** - * Return SQL script to execute after the "create all" DDL has been run. - *

    - * 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. - */ - String getDdlSeedSql(); - /** * Set a SQL script to execute after the "create all" DDL has been run. *

    @@ -1246,41 +722,16 @@ public interface DatabaseBuilder { */ void setDdlSeedSql(String ddlSeedSql); - /** - * Return a SQL script to execute before the "create all" DDL has been run. - */ - String getDdlInitSql(); - /** * Set a SQL script to execute before the "create all" DDL has been run. */ void setDdlInitSql(String ddlInitSql); - /** - * Return true if the DDL should be generated. - */ - boolean isDdlGenerate(); - - /** - * Return true if the DDL should be run. - */ - boolean isDdlRun(); - - /** - * Return true, if extra-ddl.xml should be executed. - */ - boolean isDdlExtra(); - /** * Set the header to use with DDL generation. */ void setDdlHeader(String ddlHeader); - /** - * Return the header to use with DDL generation. - */ - String getDdlHeader(); - /** * Return true if strict mode is used which includes a check that non-null columns have a default value. */ @@ -1291,31 +742,16 @@ public interface DatabaseBuilder { */ void setDdlStrictMode(boolean ddlStrictMode); - /** - * Return a comma and equals delimited placeholders that are substituted in DDL scripts. - */ - String getDdlPlaceholders(); - /** * Set a comma and equals delimited placeholders that are substituted in DDL scripts. */ void setDdlPlaceholders(String ddlPlaceholders); - /** - * Return a map of placeholder values that are substituted in DDL scripts. - */ - Map getDdlPlaceholderMap(); - /** * Set a map of placeholder values that are substituted in DDL scripts. */ void setDdlPlaceholderMap(Map ddlPlaceholderMap); - /** - * Return true if the class path search should be disabled. - */ - boolean isDisableClasspathSearch(); - /** * 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 @@ -1323,11 +759,6 @@ public interface DatabaseBuilder { */ void setDisableClasspathSearch(boolean disableClasspathSearch); - /** - * Return the mode to use for Joda LocalTime support 'normal' or 'utc'. - */ - String getJodaLocalTimeMode(); - /** * Set the mode to use for Joda LocalTime support 'normal' or 'utc'. */ @@ -1358,13 +789,6 @@ public interface DatabaseBuilder { */ void addPackage(String packageName); - /** - * Return packages to search for entities via class path search. - *

    - * This is only used if classes have not been explicitly specified. - */ - List getPackages(); - /** * Set packages to search for entities via class path search. *

    @@ -1383,77 +807,11 @@ public interface DatabaseBuilder { */ void setClasses(Collection> classes); - /** - * Return the classes registered for this database. Typically, this includes - * entities and perhaps listeners. - */ - Set> classes(); - - /** - * @deprecated - migrate to {@link #classes()}. - *

    - * Sorry if returning Set rather than List breaks code but it feels safer to - * do that than a subtle change to return a shallow copy which you will not detect. - */ - @Deprecated(forRemoval = true) - Set> getClasses(); - - /** - * Return true if L2 bean cache should be skipped once writes have occurred on a transaction. - *

    - * This defaults to true and means that for "find by id" and "find by natural key" - * queries that normally hit L2 bean cache automatically will not do so after a write/persist - * on the transaction. - *

    - *

    {@code
    -   *
    -   *   // assume Customer has L2 bean caching enabled ...
    -   *
    -   *   try (Transaction transaction = DB.beginTransaction()) {
    -   *
    -   *     // this uses L2 bean cache as the transaction
    -   *     // ... is considered "query only" at this point
    -   *     Customer.find.byId(42);
    -   *
    -   *     // transaction no longer "query only" once
    -   *     // ... a bean has been saved etc
    -   *     DB.save(someBean);
    -   *
    -   *     // will NOT use L2 bean cache as the transaction
    -   *     // ... is no longer considered "query only"
    -   *     Customer.find.byId(55);
    -   *
    -   *
    -   *
    -   *     // explicit control - please use L2 bean cache
    -   *
    -   *     transaction.setSkipCache(false);
    -   *     Customer.find.byId(77); // hit the l2 bean cache
    -   *
    -   *
    -   *     // explicit control - please don't use L2 bean cache
    -   *
    -   *     transaction.setSkipCache(true);
    -   *     Customer.find.byId(99); // skips l2 bean cache
    -   *
    -   *   }
    -   *
    -   * }
    - * - * @see Transaction#setSkipCache(boolean) - */ - boolean isSkipCacheAfterWrite(); - /** * Set to false when we still want to hit the cache after a write has occurred on a transaction. */ void setSkipCacheAfterWrite(boolean skipCacheAfterWrite); - /** - * Returns true if updates in JDBC batch default to include all properties by default. - */ - boolean isUpdateAllPropertiesInBatch(); - /** * Set to false if by default updates in JDBC batch should not include all properties. *

    @@ -1463,16 +821,12 @@ public interface DatabaseBuilder { */ void setUpdateAllPropertiesInBatch(boolean updateAllPropertiesInBatch); - /** - * Returns the resource directory. - */ - String getResourceDirectory(); - /** * Sets the resource directory. */ void setResourceDirectory(String resourceDirectory); + /** * Add a custom type mapping. *

    @@ -1518,11 +872,6 @@ public interface DatabaseBuilder { */ void add(BeanQueryAdapter beanQueryAdapter); - /** - * Return the BeanQueryAdapter instances. - */ - List getQueryAdapters(); - /** * Register all the BeanQueryAdapter instances. *

    @@ -1531,11 +880,6 @@ public interface DatabaseBuilder { */ void setQueryAdapters(List queryAdapters); - /** - * Return the custom IdGenerator instances. - */ - List getIdGenerators(); - /** * Set the custom IdGenerator instances. */ @@ -1570,41 +914,21 @@ public interface DatabaseBuilder { */ void add(BeanPostConstructListener listener); - /** - * Return the list of BeanFindController instances. - */ - List getFindControllers(); - /** * Set the list of BeanFindController instances. */ void setFindControllers(List findControllers); - /** - * Return the list of BeanPostLoader instances. - */ - List getPostLoaders(); - /** * Set the list of BeanPostLoader instances. */ void setPostLoaders(List postLoaders); - /** - * Return the list of BeanPostLoader instances. - */ - List getPostConstructListeners(); - /** * Set the list of BeanPostLoader instances. */ void setPostConstructListeners(List listeners); - /** - * Return the BeanPersistController instances. - */ - List getPersistControllers(); - /** * Register all the BeanPersistController instances. *

    @@ -1621,31 +945,16 @@ public interface DatabaseBuilder { */ void add(BeanPersistListener beanPersistListener); - /** - * Return the BeanPersistListener instances. - */ - List getPersistListeners(); - /** * Add a BulkTableEventListener */ void add(BulkTableEventListener bulkTableEventListener); - /** - * Return the list of BulkTableEventListener instances. - */ - List getBulkTableEventListeners(); - /** * Add a ServerConfigStartup. */ void addServerConfigStartup(ServerConfigStartup configStartupListener); - /** - * Return the list of ServerConfigStartup instances. - */ - List getServerConfigStartupListeners(); - /** * Register all the BeanPersistListener instances. *

    @@ -1654,17 +963,6 @@ public interface DatabaseBuilder { */ void setPersistListeners(List persistListeners); - /** - * Return the default PersistenceContextScope to be used if one is not explicitly set on a query. - *

    - * The PersistenceContextScope can specified on each query via {@link io.ebean - * .Query#setPersistenceContextScope(io.ebean.PersistenceContextScope)}. If it - * is not set on the query this default scope is used. - * - * @see Query#setPersistenceContextScope(PersistenceContextScope) - */ - PersistenceContextScope getPersistenceContextScope(); - /** * Set the PersistenceContext scope to be used if one is not explicitly set on a query. *

    @@ -1678,12 +976,6 @@ public interface DatabaseBuilder { */ void setPersistenceContextScope(PersistenceContextScope persistenceContextScope); - /** - * Return the ClassLoadConfig which is used to detect Joda, Java8 types etc and also - * create new instances of plugins given a className. - */ - ClassLoadConfig getClassLoadConfig(); - /** * Set the ClassLoadConfig which is used to detect Joda, Java8 types etc and also * create new instances of plugins given a className. @@ -1703,24 +995,12 @@ public interface DatabaseBuilder { */ void loadFromProperties(Properties properties); - /** - * Return the properties that we used for configuration and were set via a call to loadFromProperties(). - */ - Properties getProperties(); - /** * Return the PersistBatch mode to use for 'batchOnCascade' taking into account if the database * platform supports getGeneratedKeys in batch mode. */ PersistBatch appliedPersistBatchOnCascade(); - /** - * Return the Jackson ObjectMapper. - *

    - * Note that this is not strongly typed as Jackson ObjectMapper is an optional dependency. - */ - Object getObjectMapper(); - /** * Set the Jackson ObjectMapper. *

    @@ -1728,11 +1008,6 @@ public interface DatabaseBuilder { */ void setObjectMapper(Object objectMapper); - /** - * Return true if eq("someProperty", null) should to generate "1=1" rather than "is null" sql expression. - */ - boolean isExpressionEqualsWithNullAsNoop(); - /** * Set to true if you want eq("someProperty", null) to generate "1=1" rather than "is null" sql expression. *

    @@ -1742,51 +1017,26 @@ public interface DatabaseBuilder { */ void setExpressionEqualsWithNullAsNoop(boolean expressionEqualsWithNullAsNoop); - /** - * Return true if native ILIKE expression should be used if supported by the database platform (e.g. Postgres). - */ - boolean isExpressionNativeIlike(); - /** * Set to true to use native ILIKE expression if supported by the database platform (e.g. Postgres). */ void setExpressionNativeIlike(boolean expressionNativeIlike); - /** - * Return the enabled L2 cache regions. - */ - String getEnabledL2Regions(); - /** * Set the enabled L2 cache regions (comma delimited). */ void setEnabledL2Regions(String enabledL2Regions); - /** - * Return true if L2 cache is disabled. - */ - boolean isDisableL2Cache(); - /** * Set to true to disable L2 caching. Typically useful in performance testing. */ void setDisableL2Cache(boolean disableL2Cache); - /** - * Return true to use local only L2 cache. Effectively ignore l2 cache plugin like ebean-redis etc. - */ - boolean isLocalOnlyL2Cache(); - /** * Force the use of local only L2 cache. Effectively ignore l2 cache plugin like ebean-redis etc. */ void setLocalOnlyL2Cache(boolean localOnlyL2Cache); - /** - * Returns if we use javax.validation.constraints.NotNull - */ - boolean isUseValidationNotNull(); - /** * Controls if Ebean should ignore &x64;javax.validation.contstraints.NotNull or * &x64;jakarta.validation.contstraints.NotNull @@ -1798,11 +1048,6 @@ public interface DatabaseBuilder { */ void setUseValidationNotNull(boolean useValidationNotNull); - /** - * Return true if L2 cache notification should run in the foreground. - */ - boolean isNotifyL2CacheInForeground(); - /** * Set this to true to run L2 cache notification in the foreground. *

    @@ -1812,11 +1057,6 @@ public interface DatabaseBuilder { */ void setNotifyL2CacheInForeground(boolean notifyL2CacheInForeground); - /** - * Return the time to live for ebean's internal query plan. - */ - int getQueryPlanTTLSeconds(); - /** * Set the time to live for ebean's internal query plan. *

    @@ -1843,11 +1083,6 @@ public interface DatabaseBuilder { */ void addMappingLocation(String mappingLocation); - /** - * Return mapping locations to search for xml mapping via class path search. - */ - List getMappingLocations(); - /** * Set mapping locations to search for xml mapping via class path search. *

    @@ -1855,34 +1090,17 @@ public interface DatabaseBuilder { */ void setMappingLocations(List mappingLocations); - /** - * When false we need explicit @GeneratedValue mapping to assign - * Identity or Sequence generated values. When true Id properties are automatically - * assigned Identity or Sequence without the GeneratedValue mapping. - */ - boolean isIdGeneratorAutomatic(); - /** * 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); - /** - * Return true if query plan capture is enabled. - */ - boolean isQueryPlanEnable(); - /** * Set to true to enable query plan capture. */ void setQueryPlanEnable(boolean queryPlanEnable); - /** - * Return the query plan collection threshold in microseconds. - */ - long getQueryPlanThresholdMicros(); - /** * Set the query plan collection threshold in microseconds. *

    @@ -1891,35 +1109,16 @@ public interface DatabaseBuilder { */ void setQueryPlanThresholdMicros(long queryPlanThresholdMicros); - /** - * Return true if periodic capture of query plans is enabled. - */ - boolean isQueryPlanCapture(); - /** * Set to true to turn on periodic capture of query plans. */ void setQueryPlanCapture(boolean queryPlanCapture); - /** - * Return the frequency to capture query plans. - */ - long getQueryPlanCapturePeriodSecs(); - /** * Set the frequency in seconds to capture query plans. */ void setQueryPlanCapturePeriodSecs(long queryPlanCapturePeriodSecs); - /** - * Return the time after which a capture query plans request will - * stop capturing more query plans. - *

    - * Effectively this controls the amount of load/time we want to - * allow for query plan capture. - */ - long getQueryPlanCaptureMaxTimeMillis(); - /** * Set the time after which a capture query plans request will * stop capturing more query plans. @@ -1929,41 +1128,21 @@ public interface DatabaseBuilder { */ void setQueryPlanCaptureMaxTimeMillis(long queryPlanCaptureMaxTimeMillis); - /** - * Return the max number of query plans captured per request. - */ - int getQueryPlanCaptureMaxCount(); - /** * Set the max number of query plans captured per request. */ void setQueryPlanCaptureMaxCount(int queryPlanCaptureMaxCount); - /** - * Return the listener used to process captured query plans. - */ - QueryPlanListener getQueryPlanListener(); - /** * Set the listener used to process captured query plans. */ void setQueryPlanListener(QueryPlanListener queryPlanListener); - /** - * Return true if metrics should be dumped when the server is shutdown. - */ - boolean isDumpMetricsOnShutdown(); - /** * Set to true if metrics should be dumped when the server is shutdown. */ void setDumpMetricsOnShutdown(boolean dumpMetricsOnShutdown); - /** - * Return the options for dumping metrics. - */ - String getDumpMetricsOptions(); - /** * Include 'sql' or 'hash' in options such that they are included in the output. * @@ -1972,15 +1151,7 @@ public interface DatabaseBuilder { void setDumpMetricsOptions(String dumpMetricsOptions); /** - * Return true if entity classes should be loaded and registered via EntityClassRegister. - *

    - * When false we either register entity classes via application code or use classpath - * scanning to find and register entity classes. - */ - boolean isLoadModuleInfo(); - - /** - * @deprecated - migrate to {@link #isLoadModuleInfo()}. + * @deprecated - migrate to {@link Settings#isLoadModuleInfo()}. */ @Deprecated(forRemoval = true) boolean isAutoLoadModuleInfo(); @@ -1994,13 +1165,859 @@ public interface DatabaseBuilder { */ void setLoadModuleInfo(boolean loadModuleInfo); - /** - * Return the naming convention to apply to metrics names. - */ - Function getMetricNaming(); - /** * Set the naming convention to apply to metrics names. */ void setMetricNaming(Function metricNaming); + + + /** + * Provides read access (getters) for the DatabaseBuilder configuration + * that has been set. + */ + interface Settings extends DatabaseBuilder { + + /** + * Return the Jackson JsonFactory to use. + *

    + * If not set a default implementation will be used. + */ + JsonFactory getJsonFactory(); + + /** + * Get the clock used for setting the timestamps (e.g. @UpdatedTimestamp) on objects. + */ + Clock getClock(); + + /** + * Return the slow query time in millis. + */ + long getSlowQueryMillis(); + + /** + * Return the slow query event listener. + */ + SlowQueryListener getSlowQueryListener(); + + /** + * Return the service object given the key. + */ + Object getServiceObject(String key); + + /** + * Used by ebean or plugins to obtain service objects. + * + *

    {@code
    +     *
    +     *   JedisPool jedisPool = config.getServiceObject(JedisPool.class);
    +     *
    +     * }
    + * + * @param cls The type of the service object to obtain + * @return The service object given the class type + */ + @SuppressWarnings("unchecked") +

    P getServiceObject(Class

    cls); + + /** + * Return the JSON format used for DateTime types. + */ + JsonConfig.DateTime getJsonDateTime(); + + /** + * Return the JSON format used for Date types. + */ + JsonConfig.Date getJsonDate(); + + /** + * Return the JSON include mode used when writing JSON. + */ + JsonConfig.Include getJsonInclude(); + + /** + * Return the default MutableDetection to use with {@code @DbJson} using Jackson. + * + * @see DbJson#mutationDetection() + */ + MutationDetection getJsonMutationDetection(); + + /** + * Return the name of the Database. + */ + String getName(); + + /** + * Return the container / clustering configuration. + *

    + * The container holds all the Database instances and provides clustering communication + * services to all the Database instances. + */ + ContainerConfig getContainerConfig(); + + /** + * Return true if this server should be registered with the Ebean singleton + * when it is created. + *

    + * By default this is set to true. + */ + boolean isRegister(); + + /** + * Return true if this server should be registered as the "default" server + * with the Ebean singleton. + *

    + * This is only used when {@link #setRegister(boolean)} is also true. + */ + boolean isDefaultServer(); + + /** + * Return the CurrentUserProvider. This is used to populate @WhoCreated, @WhoModified and + * support other audit features (who executed a query etc). + */ + CurrentUserProvider getCurrentUserProvider(); + + /** + * Return the tenancy mode used. + */ + TenantMode getTenantMode(); + + /** + * Return the column name used for TenantMode.PARTITION. + */ + String getTenantPartitionColumn(); + + /** + * Return the current tenant provider. + */ + CurrentTenantProvider getCurrentTenantProvider(); + + /** + * Return the tenancy datasource provider. + */ + TenantDataSourceProvider getTenantDataSourceProvider(); + + /** + * Return the tenancy schema provider. + */ + TenantSchemaProvider getTenantSchemaProvider(); + + /** + * Return the PersistBatch mode to use by default 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. + */ + PersistBatch getPersistBatch(); + + /** + * Return the JDBC batch mode to use per save(), delete(), insert() or update() request. + *

    + * This makes sense when a save() or delete() cascades and executes multiple child statements. The best case + * 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. + */ + PersistBatch getPersistBatchOnCascade(); + + /** + * Return the batch size used for JDBC batching. This defaults to 20. + */ + int getPersistBatchSize(); + + /** + * Gets the query batch size. This defaults to 100. + * + * @return the query batch size + */ + int getQueryBatchSize(); + + EnumType getDefaultEnumType(); + + /** + * Return true if lazy loading is disabled on queries by default. + */ + boolean isDisableLazyLoading(); + + /** + * Return the default batch size for lazy loading of beans and collections. + */ + int getLazyLoadBatchSize(); + + + /** + * Return the default JDBC fetchSize hint for findList queries. + */ + int getJdbcFetchSizeFindList(); + + /** + * Return the default JDBC fetchSize hint for findEach/findEachWhile queries. + */ + int getJdbcFetchSizeFindEach(); + + /** + * Return the ChangeLogPrepare. + *

    + * This is used to set user context information to the ChangeSet in the + * foreground thread prior to the logging occurring in a background thread. + */ + ChangeLogPrepare getChangeLogPrepare(); + + /** + * Return the ChangeLogListener which actually performs the logging of change sets + * in the background. + */ + ChangeLogListener getChangeLogListener(); + + /** + * Return 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. + */ + ChangeLogRegister getChangeLogRegister(); + + /** + * Return true if inserts should be included in the change log by default. + */ + boolean isChangeLogIncludeInserts(); + + /** + * Return true (default) if the changelog should be written async. + */ + boolean isChangeLogAsync(); + + /** + * Return the ReadAuditLogger to use. + */ + ReadAuditLogger getReadAuditLogger(); + + /** + * Return the ReadAuditPrepare to use. + */ + ReadAuditPrepare getReadAuditPrepare(); + + /** + * Return the configuration for profiling. + */ + ProfilingConfig getProfilingConfig(); + + /** + * Return the DB schema to use. + */ + String getDbSchema(); + + /** + * Return the Geometry SRID. + */ + int getGeometrySRID(); + + /** + * Return the time zone to use when reading/writing Timestamps via JDBC. + *

    + * When set a Calendar object is used in JDBC calls when reading/writing Timestamp objects. + */ + String getDataTimeZone(); + + /** + * Return 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. + */ + String getAsOfViewSuffix(); + + /** + * Return the database column used to support history and 'As of' queries. This column is a timestamp range + * or equivalent. + */ + String getAsOfSysPeriod(); + + /** + * Return the history table suffix (defaults to _history). + */ + String getHistoryTableSuffix(); + + /** + * Return true if we are running in a JTA Transaction manager. + */ + boolean isUseJtaTransactionManager(); + + /** + * Return the external transaction manager. + */ + ExternalTransactionManager getExternalTransactionManager(); + + /** + * Return the ServerCachePlugin. + */ + ServerCachePlugin getServerCachePlugin(); + + /** + * Return true if LOB's should default to fetch eager. + * By default this is set to false and LOB's must be explicitly fetched. + */ + boolean isEagerFetchLobs(); + + /** + * Return the max call stack to use for origin location. + */ + int getMaxCallStack(); + + /** + * Return true if transactions should rollback on checked exceptions. + */ + boolean isTransactionRollbackOnChecked(); + + /** + * Return the Background executor schedule pool size. Defaults to 1. + */ + int getBackgroundExecutorSchedulePoolSize(); + + /** + * Return the Background executor shutdown seconds. This is the time allowed for the pool to shutdown nicely + * before it is forced shutdown. + */ + int getBackgroundExecutorShutdownSecs(); + + /** + * Return the background executor wrapper. + */ + BackgroundExecutorWrapper getBackgroundExecutorWrapper(); + + /** + * Return the L2 cache default max size. + */ + int getCacheMaxSize(); + + /** + * Return the L2 cache default max idle time in seconds. + */ + int getCacheMaxIdleTime(); + + /** + * Return the L2 cache default max time to live in seconds. + */ + int getCacheMaxTimeToLive(); + + /** + * Return the L2 query cache default max size. + */ + int getQueryCacheMaxSize(); + + /** + * Return the L2 query cache default max idle time in seconds. + */ + int getQueryCacheMaxIdleTime(); + + /** + * Return the L2 query cache default max time to live in seconds. + */ + int getQueryCacheMaxTimeToLive(); + + /** + * Return the NamingConvention. + *

    + * If none has been set the default UnderscoreNamingConvention is used. + */ + NamingConvention getNamingConvention(); + + /** + * Return true if all DB column and table names should use quoted identifiers. + */ + boolean isAllQuotedIdentifiers(); + + /** + * Return true if this Database is a Document store only instance (has no JDBC DB). + */ + boolean isDocStoreOnly(); + + /** + * Return the configuration for the ElasticSearch integration. + */ + DocStoreConfig getDocStoreConfig(); + + /** + * Return the constraint naming convention used in DDL generation. + */ + DbConstraintNaming getConstraintNaming(); + + /** + * Return the configuration for AutoTune. + */ + AutoTuneConfig getAutoTuneConfig(); + + /** + * Return true if the startup DataSource check should be skipped. + */ + boolean skipDataSourceCheck(); + + /** + * Return the DataSource. + */ + DataSource getDataSource(); + + /** + * Return the read only DataSource. + */ + DataSource getReadOnlyDataSource(); + + /** + * Return the configuration to build a DataSource using Ebean's own DataSource + * implementation. + */ + DataSourceBuilder getDataSourceConfig(); + + /** + * Return true if Ebean should create a DataSource for use with implicit read only transactions. + */ + boolean isAutoReadOnlyDataSource(); + + /** + * Return the configuration for the read only DataSource. + *

    + * This is only used if autoReadOnlyDataSource is true. + *

    + * The driver, url, username and password default to the configuration for the main DataSource if they are not + * set on this configuration. This means there is actually no need to set any configuration here and we only + * set configuration for url, username and password etc if it is different from the main DataSource. + */ + DataSourceBuilder getReadOnlyDataSourceConfig(); + + /** + * Return a value used to represent TRUE in the database. + *

    + * This is used for databases that do not support boolean natively. + *

    + * The value returned is either a Integer or a String (e.g. "1", or "T"). + */ + String getDatabaseBooleanTrue(); + + /** + * Return a value used to represent FALSE in the database. + *

    + * This is used for databases that do not support boolean natively. + *

    + * The value returned is either a Integer or a String (e.g. "0", or "F"). + */ + String getDatabaseBooleanFalse(); + + /** + * Return the number of DB sequence values that should be preallocated. + */ + int getDatabaseSequenceBatchSize(); + + /** + * Return the database platform name (can be null). + *

    + * If null then the platform is determined automatically via the JDBC driver + * information. + */ + String getDatabasePlatformName(); + + /** + * Return the database platform to use for this database. + */ + DatabasePlatform getDatabasePlatform(); + + /** + * Return the preferred DB platform IdType. + */ + IdType getIdType(); + + /** + * Return the EncryptKeyManager. + */ + EncryptKeyManager getEncryptKeyManager(); + + /** + * Return the EncryptDeployManager. + *

    + * This is optionally used to programmatically define which columns are + * encrypted instead of using the {@link Encrypted} Annotation. + */ + EncryptDeployManager getEncryptDeployManager(); + + /** + * Return the Encryptor used to encrypt data on the java client side (as + * opposed to DB encryption functions). + */ + Encryptor getEncryptor(); + + /** + * Return true if the Database instance should be created in offline mode. + */ + boolean isDbOffline(); + + /** + * Return the DbEncrypt used to encrypt and decrypt properties. + *

    + * Note that if this is not set then the DbPlatform may already have a + * DbEncrypt set and that will be used. + */ + DbEncrypt getDbEncrypt(); + + /** + * Return the configuration for DB types (such as UUID and custom mappings). + */ + PlatformConfig getPlatformConfig(); + + + /** + * Returns the UUID version mode. + */ + DatabaseConfig.UuidVersion getUuidVersion(); + + /** + * Return the UUID state file. + */ + String getUuidStateFile(); + + /** + * Returns the V1-UUID-NodeId + */ + String getUuidNodeId(); + + /** + * Return true if LocalTime should be persisted with nanos precision. + */ + boolean isLocalTimeWithNanos(); + + /** + * Return true if Duration should be persisted with nanos precision (SQL DECIMAL). + *

    + * Otherwise it is persisted with second precision (SQL INTEGER). + */ + boolean isDurationWithNanos(); + + /** + * Return true if the DB migration should run on server start. + */ + boolean isRunMigration(); + + /** + * Return true if the "drop all ddl" should be skipped. + *

    + * 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. + */ + boolean isDdlCreateOnly(); + + /** + * Return SQL script to execute after the "create all" DDL has been run. + *

    + * 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. + */ + String getDdlSeedSql(); + + /** + * Return a SQL script to execute before the "create all" DDL has been run. + */ + String getDdlInitSql(); + + /** + * Return true if the DDL should be generated. + */ + boolean isDdlGenerate(); + + /** + * Return true if the DDL should be run. + */ + boolean isDdlRun(); + + /** + * Return true, if extra-ddl.xml should be executed. + */ + boolean isDdlExtra(); + + /** + * Return the header to use with DDL generation. + */ + String getDdlHeader(); + + /** + * Return a comma and equals delimited placeholders that are substituted in DDL scripts. + */ + String getDdlPlaceholders(); + + /** + * Return a map of placeholder values that are substituted in DDL scripts. + */ + Map getDdlPlaceholderMap(); + + /** + * Return true if the class path search should be disabled. + */ + boolean isDisableClasspathSearch(); + + /** + * Return the mode to use for Joda LocalTime support 'normal' or 'utc'. + */ + String getJodaLocalTimeMode(); + + /** + * Return packages to search for entities via class path search. + *

    + * This is only used if classes have not been explicitly specified. + */ + List getPackages(); + + /** + * Return the classes registered for this database. Typically, this includes + * entities and perhaps listeners. + */ + Set> classes(); + + /** + * Return true if L2 bean cache should be skipped once writes have occurred on a transaction. + *

    + * This defaults to true and means that for "find by id" and "find by natural key" + * queries that normally hit L2 bean cache automatically will not do so after a write/persist + * on the transaction. + *

    + *

    {@code
    +     *
    +     *   // assume Customer has L2 bean caching enabled ...
    +     *
    +     *   try (Transaction transaction = DB.beginTransaction()) {
    +     *
    +     *     // this uses L2 bean cache as the transaction
    +     *     // ... is considered "query only" at this point
    +     *     Customer.find.byId(42);
    +     *
    +     *     // transaction no longer "query only" once
    +     *     // ... a bean has been saved etc
    +     *     DB.save(someBean);
    +     *
    +     *     // will NOT use L2 bean cache as the transaction
    +     *     // ... is no longer considered "query only"
    +     *     Customer.find.byId(55);
    +     *
    +     *
    +     *
    +     *     // explicit control - please use L2 bean cache
    +     *
    +     *     transaction.setSkipCache(false);
    +     *     Customer.find.byId(77); // hit the l2 bean cache
    +     *
    +     *
    +     *     // explicit control - please don't use L2 bean cache
    +     *
    +     *     transaction.setSkipCache(true);
    +     *     Customer.find.byId(99); // skips l2 bean cache
    +     *
    +     *   }
    +     *
    +     * }
    + * + * @see Transaction#setSkipCache(boolean) + */ + boolean isSkipCacheAfterWrite(); + + /** + * Returns true if updates in JDBC batch default to include all properties by default. + */ + boolean isUpdateAllPropertiesInBatch(); + + /** + * Returns the resource directory. + */ + String getResourceDirectory(); + + /** + * @deprecated - migrate to {@link Settings#classes()}. + *

    + * Sorry if returning Set rather than List breaks code but it feels safer to + * do that than a subtle change to return a shallow copy which you will not detect. + */ + @Deprecated(forRemoval = true) + Set> getClasses(); + + /** + * Return the BeanQueryAdapter instances. + */ + List getQueryAdapters(); + + /** + * Return the custom IdGenerator instances. + */ + List getIdGenerators(); + + /** + * Return the list of BeanFindController instances. + */ + List getFindControllers(); + + /** + * Return the list of BeanPostLoader instances. + */ + List getPostLoaders(); + + /** + * Return the list of BeanPostLoader instances. + */ + List getPostConstructListeners(); + + /** + * Return the BeanPersistController instances. + */ + List getPersistControllers(); + + /** + * Return the BeanPersistListener instances. + */ + List getPersistListeners(); + + /** + * Return the list of BulkTableEventListener instances. + */ + List getBulkTableEventListeners(); + + /** + * Return the list of ServerConfigStartup instances. + */ + List getServerConfigStartupListeners(); + + /** + * Return the default PersistenceContextScope to be used if one is not explicitly set on a query. + *

    + * The PersistenceContextScope can specified on each query via {@link io.ebean + * .Query#setPersistenceContextScope(io.ebean.PersistenceContextScope)}. If it + * is not set on the query this default scope is used. + * + * @see Query#setPersistenceContextScope(PersistenceContextScope) + */ + PersistenceContextScope getPersistenceContextScope(); + + /** + * Return the ClassLoadConfig which is used to detect Joda, Java8 types etc and also + * create new instances of plugins given a className. + */ + ClassLoadConfig getClassLoadConfig(); + + /** + * Return the properties that we used for configuration and were set via a call to loadFromProperties(). + */ + Properties getProperties(); + + /** + * Return the Jackson ObjectMapper. + *

    + * Note that this is not strongly typed as Jackson ObjectMapper is an optional dependency. + */ + Object getObjectMapper(); + + /** + * Return true if eq("someProperty", null) should to generate "1=1" rather than "is null" sql expression. + */ + boolean isExpressionEqualsWithNullAsNoop(); + + /** + * Return true if native ILIKE expression should be used if supported by the database platform (e.g. Postgres). + */ + boolean isExpressionNativeIlike(); + + /** + * Return the enabled L2 cache regions. + */ + String getEnabledL2Regions(); + + /** + * Return true if L2 cache is disabled. + */ + boolean isDisableL2Cache(); + + /** + * Return true to use local only L2 cache. Effectively ignore l2 cache plugin like ebean-redis etc. + */ + boolean isLocalOnlyL2Cache(); + + /** + * Returns if we use javax.validation.constraints.NotNull + */ + boolean isUseValidationNotNull(); + + /** + * Return true if L2 cache notification should run in the foreground. + */ + boolean isNotifyL2CacheInForeground(); + + /** + * Return the time to live for ebean's internal query plan. + */ + int getQueryPlanTTLSeconds(); + + /** + * Return mapping locations to search for xml mapping via class path search. + */ + List getMappingLocations(); + + /** + * When false we need explicit @GeneratedValue mapping to assign + * Identity or Sequence generated values. When true Id properties are automatically + * assigned Identity or Sequence without the GeneratedValue mapping. + */ + boolean isIdGeneratorAutomatic(); + + /** + * Return true if query plan capture is enabled. + */ + boolean isQueryPlanEnable(); + + /** + * Return the query plan collection threshold in microseconds. + */ + long getQueryPlanThresholdMicros(); + + /** + * Return true if periodic capture of query plans is enabled. + */ + boolean isQueryPlanCapture(); + + /** + * Return the frequency to capture query plans. + */ + long getQueryPlanCapturePeriodSecs(); + + /** + * Return the time after which a capture query plans request will + * stop capturing more query plans. + *

    + * Effectively this controls the amount of load/time we want to + * allow for query plan capture. + */ + long getQueryPlanCaptureMaxTimeMillis(); + + /** + * Return the max number of query plans captured per request. + */ + int getQueryPlanCaptureMaxCount(); + + /** + * Return the listener used to process captured query plans. + */ + QueryPlanListener getQueryPlanListener(); + + /** + * Return true if metrics should be dumped when the server is shutdown. + */ + boolean isDumpMetricsOnShutdown(); + + /** + * Return the options for dumping metrics. + */ + String getDumpMetricsOptions(); + + /** + * Return true if entity classes should be loaded and registered via EntityClassRegister. + *

    + * When false we either register entity classes via application code or use classpath + * scanning to find and register entity classes. + */ + boolean isLoadModuleInfo(); + + /** + * Return the naming convention to apply to metrics names. + */ + Function getMetricNaming(); + + } } diff --git a/ebean-api/src/main/java/io/ebean/DatabaseFactory.java b/ebean-api/src/main/java/io/ebean/DatabaseFactory.java index a5eb97d2c..f887c1416 100644 --- a/ebean-api/src/main/java/io/ebean/DatabaseFactory.java +++ b/ebean-api/src/main/java/io/ebean/DatabaseFactory.java @@ -75,9 +75,10 @@ public final class DatabaseFactory { * * } */ - public static Database create(DatabaseBuilder config) { + public static Database create(DatabaseBuilder builder) { lock.lock(); try { + var config = builder.settings(); if (config.getName() == null) { throw new PersistenceException("The name is null (it is required)"); } @@ -131,7 +132,7 @@ public final class DatabaseFactory { } } - private static Database createInternal(DatabaseBuilder config) { + private static Database createInternal(DatabaseBuilder.Settings config) { return container(config.getContainerConfig()).createServer(config); } 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 2e3a29d36..0b614f2e5 100644 --- a/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java +++ b/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java @@ -61,7 +61,7 @@ import java.util.function.Function; * @author rbygrave * @see DatabaseFactory */ -public class DatabaseConfig implements DatabaseBuilder { +public class DatabaseConfig implements DatabaseBuilder.Settings { /** * The Database name. @@ -548,6 +548,11 @@ public class DatabaseConfig implements DatabaseBuilder { public DatabaseConfig() { } + @Override + public Settings settings() { + return this; + } + @Override public Clock getClock() { return clock; diff --git a/ebean-api/src/main/java/io/ebean/plugin/SpiServer.java b/ebean-api/src/main/java/io/ebean/plugin/SpiServer.java index 9f558571a..59d3dea2c 100644 --- a/ebean-api/src/main/java/io/ebean/plugin/SpiServer.java +++ b/ebean-api/src/main/java/io/ebean/plugin/SpiServer.java @@ -16,7 +16,7 @@ public interface SpiServer extends Database { /** * Return the DatabaseConfig. */ - DatabaseBuilder config(); + DatabaseBuilder.Settings config(); /** * Return the DatabasePlatform for this database. diff --git a/ebean-api/src/test/java/io/ebean/config/DatabaseConfigTest.java b/ebean-api/src/test/java/io/ebean/config/DatabaseConfigTest.java index 9e19c484a..d816584b2 100644 --- a/ebean-api/src/test/java/io/ebean/config/DatabaseConfigTest.java +++ b/ebean-api/src/test/java/io/ebean/config/DatabaseConfigTest.java @@ -18,7 +18,7 @@ class DatabaseConfigTest { @Test void testLoadFromEbeanProperties() { - DatabaseBuilder config = new DatabaseConfig(); + var config = new DatabaseConfig().settings(); config.loadFromProperties(); assertEquals(PersistBatch.NONE, config.getPersistBatch()); @@ -33,7 +33,7 @@ class DatabaseConfigTest { Properties props = new Properties(); props.setProperty("ddl.initSql", "${user.home}" + fileSeparator + "initSql"); - DatabaseBuilder config = new DatabaseConfig(); + var config = new DatabaseConfig().settings(); config.loadFromProperties(props); String ddlInitSql = config.getDdlInitSql(); @@ -84,46 +84,47 @@ class DatabaseConfigTest { config.loadFromProperties(props); - assertFalse(config.isDefaultServer()); - assertTrue(config.isDisableL2Cache()); - assertTrue(config.isNotifyL2CacheInForeground()); - assertTrue(config.isDbOffline()); - assertTrue(config.isAutoReadOnlyDataSource()); - assertTrue(config.isAutoLoadModuleInfo()); - assertTrue(config.isLoadModuleInfo()); - assertTrue(config.skipDataSourceCheck()); + var settings = config.settings(); + assertFalse(settings.isDefaultServer()); + assertTrue(settings.isDisableL2Cache()); + assertTrue(settings.isNotifyL2CacheInForeground()); + assertTrue(settings.isDbOffline()); + assertTrue(settings.isAutoReadOnlyDataSource()); + assertTrue(settings.isAutoLoadModuleInfo()); + assertTrue(settings.isLoadModuleInfo()); + assertTrue(settings.skipDataSourceCheck()); - assertTrue(config.isIdGeneratorAutomatic()); - assertFalse(config.getPlatformConfig().isCaseSensitiveCollation()); - assertTrue(config.getPlatformConfig().isForUpdateNoKey()); + assertTrue(settings.isIdGeneratorAutomatic()); + assertFalse(settings.getPlatformConfig().isCaseSensitiveCollation()); + assertTrue(settings.getPlatformConfig().isForUpdateNoKey()); - assertThat(config.getNamingConvention()).isInstanceOf(MatchingNamingConvention.class); + assertThat(settings.getNamingConvention()).isInstanceOf(MatchingNamingConvention.class); - assertEquals(MutationDetection.NONE, config.getJsonMutationDetection()); + assertEquals(MutationDetection.NONE, settings.getJsonMutationDetection()); config.setJsonMutationDetection(MutationDetection.SOURCE); - assertEquals(MutationDetection.SOURCE, config.getJsonMutationDetection()); - assertEquals(IdType.SEQUENCE, config.getIdType()); - assertEquals(PersistBatch.ALL, config.getPersistBatch()); - assertEquals(PersistBatch.ALL, config.getPersistBatchOnCascade()); - Assertions.assertEquals(PlatformConfig.DbUuid.BINARY, config.getPlatformConfig().getDbUuid()); - Assertions.assertEquals(JsonConfig.DateTime.MILLIS, config.getJsonDateTime()); - assertEquals(JsonConfig.Date.MILLIS, config.getJsonDate()); + assertEquals(MutationDetection.SOURCE, settings.getJsonMutationDetection()); + assertEquals(IdType.SEQUENCE, settings.getIdType()); + assertEquals(PersistBatch.ALL, settings.getPersistBatch()); + assertEquals(PersistBatch.ALL, settings.getPersistBatchOnCascade()); + Assertions.assertEquals(PlatformConfig.DbUuid.BINARY, settings.getPlatformConfig().getDbUuid()); + Assertions.assertEquals(JsonConfig.DateTime.MILLIS, settings.getJsonDateTime()); + assertEquals(JsonConfig.Date.MILLIS, settings.getJsonDate()); - assertEquals("r0,users,orgs", config.getEnabledL2Regions()); + assertEquals("r0,users,orgs", settings.getEnabledL2Regions()); - assertEquals(42, config.getJdbcFetchSizeFindEach()); - assertEquals(43, config.getJdbcFetchSizeFindList()); - assertEquals(4, config.getBackgroundExecutorSchedulePoolSize()); - assertEquals(98, config.getBackgroundExecutorShutdownSecs()); + assertEquals(42, settings.getJdbcFetchSizeFindEach()); + assertEquals(43, settings.getJdbcFetchSizeFindList()); + assertEquals(4, settings.getBackgroundExecutorSchedulePoolSize()); + assertEquals(98, settings.getBackgroundExecutorShutdownSecs()); - assertTrue(config.isQueryPlanEnable()); - assertEquals(10000, config.getQueryPlanThresholdMicros()); - assertTrue(config.isQueryPlanCapture()); - assertEquals(42, config.getQueryPlanCapturePeriodSecs()); - assertEquals(560, config.getQueryPlanCaptureMaxTimeMillis()); - assertEquals(7, config.getQueryPlanCaptureMaxCount()); + assertTrue(settings.isQueryPlanEnable()); + assertEquals(10000, settings.getQueryPlanThresholdMicros()); + assertTrue(settings.isQueryPlanCapture()); + assertEquals(42, settings.getQueryPlanCapturePeriodSecs()); + assertEquals(560, settings.getQueryPlanCaptureMaxTimeMillis()); + assertEquals(7, settings.getQueryPlanCaptureMaxCount()); - assertThat(config.getMappingLocations()).containsExactly("classpath:/foo","bar"); + assertThat(settings.getMappingLocations()).containsExactly("classpath:/foo","bar"); config.setPersistBatch(PersistBatch.NONE); config.setPersistBatchOnCascade(PersistBatch.NONE); @@ -138,19 +139,19 @@ class DatabaseConfigTest { props1.setProperty("ebean.notifyL2CacheInForeground", "false"); config.loadFromProperties(props1); - assertFalse(config.isDisableL2Cache()); - assertFalse(config.isNotifyL2CacheInForeground()); + assertFalse(settings.isDisableL2Cache()); + assertFalse(settings.isNotifyL2CacheInForeground()); - assertEquals(PersistBatch.ALL, config.getPersistBatch()); - assertEquals(PersistBatch.ALL, config.getPersistBatchOnCascade()); + assertEquals(PersistBatch.ALL, settings.getPersistBatch()); + assertEquals(PersistBatch.ALL, settings.getPersistBatchOnCascade()); config.setEnabledL2Regions("r0,orgs"); - assertEquals("r0,orgs", config.getEnabledL2Regions()); + assertEquals("r0,orgs", settings.getEnabledL2Regions()); } @Test void test_defaults() { - DatabaseBuilder config = new DatabaseConfig(); + DatabaseBuilder.Settings config = new DatabaseConfig().settings(); assertTrue(config.isIdGeneratorAutomatic()); assertTrue(config.isDefaultServer()); assertFalse(config.isAutoPersistUpdates()); @@ -185,7 +186,7 @@ class DatabaseConfigTest { void test_putServiceObject() { ObjectMapper objectMapper = new ObjectMapper(); - DatabaseBuilder config = new DatabaseConfig(); + var config = new DatabaseConfig().settings(); config.putServiceObject(objectMapper); ObjectMapper mapper0 = config.getServiceObject(ObjectMapper.class); diff --git a/ebean-bom/pom.xml b/ebean-bom/pom.xml index 54e4b0a8e..f82651f6e 100644 --- a/ebean-bom/pom.xml +++ b/ebean-bom/pom.xml @@ -113,13 +113,13 @@ io.ebean ebean-joda-time - 13.24.0-RC1 + 13.24.0-RC2 io.ebean ebean-jackson-jsonnode - 13.24.0-RC1 + 13.24.0-RC2 diff --git a/ebean-core-type/src/main/java/io/ebean/core/type/ExtraTypeFactory.java b/ebean-core-type/src/main/java/io/ebean/core/type/ExtraTypeFactory.java index e4da6fd7b..010f86fec 100644 --- a/ebean-core-type/src/main/java/io/ebean/core/type/ExtraTypeFactory.java +++ b/ebean-core-type/src/main/java/io/ebean/core/type/ExtraTypeFactory.java @@ -12,5 +12,5 @@ public interface ExtraTypeFactory { /** * Provide extra types to Ebean. */ - List> createTypes(DatabaseBuilder config, Object objectMapper); + List> createTypes(DatabaseBuilder.Settings config, Object objectMapper); } diff --git a/ebean-core-type/src/main/java/io/ebean/core/type/ScalarTypeSetFactory.java b/ebean-core-type/src/main/java/io/ebean/core/type/ScalarTypeSetFactory.java index 89a6187d1..44ef36d72 100644 --- a/ebean-core-type/src/main/java/io/ebean/core/type/ScalarTypeSetFactory.java +++ b/ebean-core-type/src/main/java/io/ebean/core/type/ScalarTypeSetFactory.java @@ -12,6 +12,6 @@ public interface ScalarTypeSetFactory { * Create the ScalarTypeSet given the config and optional objectMapper. */ @Nullable - ScalarTypeSet createTypeSet(DatabaseBuilder config, @Nullable Object objectMapper); + ScalarTypeSet createTypeSet(DatabaseBuilder.Settings config, @Nullable Object objectMapper); } diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/GeoTypeProvider.java b/ebean-core/src/main/java/io/ebeaninternal/api/GeoTypeProvider.java index e9dcd6ebe..59566e437 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/api/GeoTypeProvider.java +++ b/ebean-core/src/main/java/io/ebeaninternal/api/GeoTypeProvider.java @@ -11,5 +11,5 @@ public interface GeoTypeProvider { /** * Create a binder for binding geometry types. */ - GeoTypeBinder createBinder(DatabaseBuilder config); + GeoTypeBinder createBinder(DatabaseBuilder.Settings config); } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/cache/CacheManagerOptions.java b/ebean-core/src/main/java/io/ebeaninternal/server/cache/CacheManagerOptions.java index e3af6137c..deda681e2 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/cache/CacheManagerOptions.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/cache/CacheManagerOptions.java @@ -13,7 +13,7 @@ import io.ebeaninternal.server.cluster.ClusterManager; public final class CacheManagerOptions { private final ClusterManager clusterManager; - private final DatabaseBuilder databaseBuilder; + private final DatabaseBuilder.Settings databaseBuilder; private final boolean localL2Caching; private CurrentTenantProvider currentTenantProvider; private QueryCacheEntryValidate queryCacheEntryValidate; @@ -30,7 +30,7 @@ public final class CacheManagerOptions { this.queryDefault = new ServerCacheOptions(); } - public CacheManagerOptions(ClusterManager clusterManager, DatabaseBuilder config, boolean localL2Caching) { + public CacheManagerOptions(ClusterManager clusterManager, DatabaseBuilder.Settings config, boolean localL2Caching) { this.clusterManager = clusterManager; this.databaseBuilder = config; this.localL2Caching = localL2Caching; diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/ClassPathScanners.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/ClassPathScanners.java index 18b6a1d5b..d62dbde8c 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/ClassPathScanners.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/ClassPathScanners.java @@ -16,7 +16,7 @@ public class ClassPathScanners { /** * Return the list of ClassPathScanner services using DatabaseConfig service loader. */ - public static List find(DatabaseBuilder config) { + public static List find(DatabaseBuilder.Settings config) { List scanners = new ArrayList<>(); for (ClassPathScannerFactory factory : ServiceLoader.load(ClassPathScannerFactory.class)) { scanners.add(factory.createScanner(config.getClassLoadConfig().getClassLoader())); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/DatabasePlatformFactory.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/DatabasePlatformFactory.java index 016722848..20a693e6e 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/DatabasePlatformFactory.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/DatabasePlatformFactory.java @@ -37,7 +37,7 @@ public class DatabasePlatformFactory { /** * Create the appropriate database specific platform. */ - public DatabasePlatform create(DatabaseBuilder config) { + public DatabasePlatform create(DatabaseBuilder.Settings config) { try { String offlinePlatform = DbOffline.getPlatform(); if (offlinePlatform != null) { diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultContainer.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultContainer.java index 3cd1c4713..70cb3ce52 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultContainer.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultContainer.java @@ -58,7 +58,8 @@ public final class DefaultContainer implements SpiContainer { return createServer(config); } - private SpiBackgroundExecutor createBackgroundExecutor(DatabaseBuilder config) { + private SpiBackgroundExecutor createBackgroundExecutor(DatabaseBuilder builder) { + var config = builder.settings(); String namePrefix = "ebean-" + config.getName(); int schedulePoolSize = config.getBackgroundExecutorSchedulePoolSize(); int shutdownSecs = config.getBackgroundExecutorShutdownSecs(); @@ -70,9 +71,10 @@ public final class DefaultContainer implements SpiContainer { * Create the implementation from the configuration. */ @Override - public SpiEbeanServer createServer(DatabaseBuilder config) { + public SpiEbeanServer createServer(DatabaseBuilder builder) { lock.lock(); try { + var config = builder.settings(); long start = System.currentTimeMillis(); applyConfigServices(config); setNamingConvention(config); @@ -116,7 +118,7 @@ public final class DefaultContainer implements SpiContainer { } } - private void applyConfigServices(DatabaseBuilder config) { + private void applyConfigServices(DatabaseBuilder.Settings config) { if (config.isDefaultServer()) { for (DatabaseConfigProvider configProvider : ServiceLoader.load(DatabaseConfigProvider.class)) { configProvider.apply(config); @@ -159,7 +161,7 @@ public final class DefaultContainer implements SpiContainer { * Get the entities, scalarTypes, Listeners etc combining the class registered * ones with the already created instances. */ - private BootupClasses bootupClasses(DatabaseBuilder config) { + private BootupClasses bootupClasses(DatabaseBuilder.Settings config) { BootupClasses bootup = bootupClasses1(config); bootup.addServerConfigStartup(config.getServerConfigStartupListeners()); bootup.runServerConfigStartup(config); @@ -177,7 +179,7 @@ public final class DefaultContainer implements SpiContainer { /** * Get the class based entities, scalarTypes, Listeners etc. */ - private BootupClasses bootupClasses1(DatabaseBuilder config) { + private BootupClasses bootupClasses1(DatabaseBuilder.Settings config) { Set> classes = config.classes(); if (config.isDisableClasspathSearch() || (classes != null && !classes.isEmpty())) { // use classes we explicitly added via configuration @@ -189,7 +191,7 @@ public final class DefaultContainer implements SpiContainer { /** * Set the naming convention to underscore if it has not already been set. */ - private void setNamingConvention(DatabaseBuilder config) { + private void setNamingConvention(DatabaseBuilder.Settings config) { if (config.getNamingConvention() == null) { config.setNamingConvention(new UnderscoreNamingConvention()); } @@ -198,7 +200,7 @@ public final class DefaultContainer implements SpiContainer { /** * Set the DatabasePlatform if it has not already been set. */ - private void setDatabasePlatform(DatabaseBuilder config) { + private void setDatabasePlatform(DatabaseBuilder.Settings config) { DatabasePlatform platform = config.getDatabasePlatform(); if (platform == null) { if (config.getTenantMode().isDynamicDataSource()) { @@ -214,7 +216,7 @@ public final class DefaultContainer implements SpiContainer { /** * Set the DataSource if it has not already been set. */ - private void setDataSource(DatabaseBuilder config) { + private void setDataSource(DatabaseBuilder.Settings config) { if (isOfflineMode(config)) { log.log(DEBUG, "... DbOffline using platform [{0}]", DbOffline.getPlatform()); } else { @@ -222,7 +224,7 @@ public final class DefaultContainer implements SpiContainer { } } - private boolean isOfflineMode(DatabaseBuilder config) { + private boolean isOfflineMode(DatabaseBuilder.Settings config) { return config.isDbOffline() || DbOffline.isSet(); } @@ -236,7 +238,7 @@ public final class DefaultContainer implements SpiContainer { * checking may not work as expected. *

    */ - private boolean checkDataSource(DatabaseBuilder config) { + private boolean checkDataSource(DatabaseBuilder.Settings config) { if (isOfflineMode(config)) { return false; } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java index b9927be90..3327cd133 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java @@ -76,7 +76,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { private static final System.Logger log = CoreLog.internal; private final ReentrantLock lock = new ReentrantLock(); - private final DatabaseBuilder config; + private final DatabaseBuilder.Settings config; private final String serverName; private final DatabasePlatform databasePlatform; private final TransactionManager transactionManager; @@ -170,7 +170,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { /** * Create the CallStackFactory depending if AutoTune is being used. */ - private CallOriginFactory initCallStackFactory(DatabaseBuilder config) { + private CallOriginFactory initCallStackFactory(DatabaseBuilder.Settings config) { if (!config.getAutoTuneConfig().isActive()) { // use a common CallStack for performance as we don't care with no AutoTune return new NoopCallOriginFactory(); @@ -224,7 +224,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer { } @Override - public DatabaseBuilder config() { + public DatabaseBuilder.Settings config() { return config; } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/InitDataSource.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/InitDataSource.java index 631c0b7d8..b40b740e9 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/InitDataSource.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/InitDataSource.java @@ -12,16 +12,16 @@ import javax.sql.DataSource; */ final class InitDataSource { - private final DatabaseBuilder config; + private final DatabaseBuilder.Settings config; /** * Create and set the main DataSource and read-only DataSource. */ - static void init(DatabaseBuilder config) { + static void init(DatabaseBuilder.Settings config) { new InitDataSource(config).initialise(); } - InitDataSource(DatabaseBuilder config) { + InitDataSource(DatabaseBuilder.Settings config) { this.config = config; } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/InternalConfiguration.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/InternalConfiguration.java index cf49f1637..9e2dbbfdc 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/InternalConfiguration.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/InternalConfiguration.java @@ -69,7 +69,7 @@ public final class InternalConfiguration { private final TableModState tableModState; private final boolean online; - private final DatabaseBuilder config; + private final DatabaseBuilder.Settings config; private final BootupClasses bootupClasses; private final DatabasePlatform databasePlatform; private final DeployInherit deployInherit; @@ -98,12 +98,12 @@ public final class InternalConfiguration { private boolean localL2Caching; InternalConfiguration(boolean online, ClusterManager clusterManager, SpiBackgroundExecutor backgroundExecutor, - DatabaseBuilder config, BootupClasses bootupClasses) { + DatabaseBuilder.Settings config, BootupClasses bootupClasses) { this.online = online; this.config = config; this.jacksonCorePresent = config.getClassLoadConfig().isJacksonCorePresent(); - this.clockService = new ClockService(config.getClock()); + this.clockService = new ClockService(config.settings().getClock()); this.tableModState = new TableModState(); this.logManager = initLogManager(); this.docStoreFactory = initDocStoreFactory(service(DocStoreFactory.class)); @@ -173,7 +173,7 @@ public final class InternalConfiguration { /** * Create and return the ExpressionFactory based on configuration and database platform. */ - private ExpressionFactory initExpressionFactory(DatabaseBuilder config) { + private ExpressionFactory initExpressionFactory(DatabaseBuilder.Settings config) { boolean nativeIlike = config.isExpressionNativeIlike() && databasePlatform.supportsNativeIlike(); return new DefaultExpressionFactory(config.isExpressionEqualsWithNullAsNoop(), nativeIlike); } @@ -331,7 +331,7 @@ public final class InternalConfiguration { return config.getDatabasePlatform(); } - public DatabaseBuilder getConfig() { + public DatabaseBuilder.Settings getConfig() { return config; } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/bootup/BootupClassPathSearch.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/bootup/BootupClassPathSearch.java index 7d0b43c5f..0db785d1c 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/bootup/BootupClassPathSearch.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/bootup/BootupClassPathSearch.java @@ -24,11 +24,11 @@ public class BootupClassPathSearch { * Search the classPath for the classes we are interested in returning * them as BootupClasses. */ - public static BootupClasses search(DatabaseBuilder config) { + public static BootupClasses search(DatabaseBuilder.Settings config) { return new BootupClassPathSearch(config).getBootupClasses(); } - private BootupClassPathSearch(DatabaseBuilder config) { + private BootupClassPathSearch(DatabaseBuilder.Settings config) { // find packages defined in ebean.mf resources Set mfPackages = ManifestReader.create(config.getClassLoadConfig().getClassLoader()) .read("META-INF/ebean.mf") diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/bootup/BootupClasses.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/bootup/BootupClasses.java index 0a01cfa4a..726411dd2 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/bootup/BootupClasses.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/bootup/BootupClasses.java @@ -172,7 +172,7 @@ public class BootupClasses implements Predicate> { add(startupInstances, serverConfigStartupInstances, serverConfigStartupCandidates); } - public void addChangeLogInstances(DatabaseBuilder config) { + public void addChangeLogInstances(DatabaseBuilder.Settings config) { readAuditPrepare = config.getReadAuditPrepare(); readAuditLogger = config.getReadAuditLogger(); changeLogPrepare = config.getChangeLogPrepare(); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptor.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptor.java index 9efe9f306..06930f128 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptor.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptor.java @@ -423,7 +423,7 @@ public class BeanDescriptor implements BeanType, STreeType, SpiBeanType { /** * Return the DatabaseConfig. */ - public DatabaseBuilder config() { + public DatabaseBuilder.Settings config() { return owner.config(); } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorManager.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorManager.java index ec0aca791..240ab41a2 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorManager.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorManager.java @@ -79,7 +79,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy private final NamingConvention namingConvention; private final DeployCreateProperties createProperties; private final BeanManagerFactory beanManagerFactory; - private final DatabaseBuilder config; + private final DatabaseBuilder.Settings config; private final ChangeLogListener changeLogListener; private final ChangeLogRegister changeLogRegister; private final ChangeLogPrepare changeLogPrepare; @@ -196,19 +196,19 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy /** * Return the AsOfViewSuffix based on the DbHistorySupport. */ - private String asOfViewSuffix(DatabasePlatform databasePlatform, DatabaseBuilder serverConfig) { + private String asOfViewSuffix(DatabasePlatform databasePlatform, DatabaseBuilder.Settings config) { DbHistorySupport historySupport = databasePlatform.historySupport(); // with historySupport returns a simple view suffix or the sql2011 as of timestamp suffix - return (historySupport == null) ? serverConfig.getAsOfViewSuffix() : historySupport.getAsOfViewSuffix(serverConfig.getAsOfViewSuffix()); + return (historySupport == null) ? config.getAsOfViewSuffix() : historySupport.getAsOfViewSuffix(config.getAsOfViewSuffix()); } /** * Return the versions between timestamp suffix based on the DbHistorySupport. */ - private String versionsBetweenSuffix(DatabasePlatform databasePlatform, DatabaseBuilder serverConfig) { + private String versionsBetweenSuffix(DatabasePlatform databasePlatform, DatabaseBuilder.Settings config) { DbHistorySupport historySupport = databasePlatform.historySupport(); // with historySupport returns a simple view suffix or the sql2011 versions between timestamp suffix - return (historySupport == null) ? serverConfig.getAsOfViewSuffix() : historySupport.getVersionsBetweenSuffix(serverConfig.getAsOfViewSuffix()); + return (historySupport == null) ? config.getAsOfViewSuffix() : historySupport.getVersionsBetweenSuffix(config.getAsOfViewSuffix()); } @Override @@ -217,7 +217,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy } @Override - public DatabaseBuilder config() { + public DatabaseBuilder.Settings config() { return config; } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorMap.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorMap.java index 5aa2d0166..e95cf2f12 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorMap.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorMap.java @@ -25,7 +25,7 @@ public interface BeanDescriptorMap { /** * Return the DatabaseConfig. */ - DatabaseBuilder config(); + DatabaseBuilder.Settings config(); /** * Return the Cache Manager. diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanLifecycleAdapterFactory.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanLifecycleAdapterFactory.java index 4de9279b3..4eeff5f4a 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanLifecycleAdapterFactory.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanLifecycleAdapterFactory.java @@ -34,7 +34,7 @@ final class BeanLifecycleAdapterFactory { private final boolean postConstructPresent; - BeanLifecycleAdapterFactory(DatabaseBuilder config) { + BeanLifecycleAdapterFactory(DatabaseBuilder.Settings config) { this.postConstructPresent = config.getClassLoadConfig().isJavaxPostConstructPresent(); } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/generatedproperty/GeneratedPropertyFactory.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/generatedproperty/GeneratedPropertyFactory.java index b920054cf..ff4b40a56 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/generatedproperty/GeneratedPropertyFactory.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/generatedproperty/GeneratedPropertyFactory.java @@ -27,7 +27,7 @@ public final class GeneratedPropertyFactory { private final ClassLoadConfig classLoadConfig; private final Map idGeneratorMap = new HashMap<>(); - public GeneratedPropertyFactory(boolean offlineMode, DatabaseBuilder config, List idGenerators) { + public GeneratedPropertyFactory(boolean offlineMode, DatabaseBuilder.Settings config, List idGenerators) { this.classLoadConfig = config.getClassLoadConfig(); this.insertFactory = new InsertTimestampFactory(classLoadConfig); this.updateFactory = new UpdateTimestampFactory(classLoadConfig); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanDescriptor.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanDescriptor.java index ecc455152..1f56614d1 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanDescriptor.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanDescriptor.java @@ -47,7 +47,7 @@ public class DeployBeanDescriptor { private static final PropOrder PROP_ORDER = new PropOrder(); - private final DatabaseBuilder config; + private final DatabaseBuilder.Settings config; private final BeanDescriptorManager manager; /** * Map of BeanProperty Linked so as to preserve order. @@ -133,7 +133,7 @@ public class DeployBeanDescriptor { /** * Construct the BeanDescriptor. */ - public DeployBeanDescriptor(BeanDescriptorManager manager, Class beanType, DatabaseBuilder config) { + public DeployBeanDescriptor(BeanDescriptorManager manager, Class beanType, DatabaseBuilder.Settings config) { this.manager = manager; this.config = config; this.beanType = beanType; diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/DeployUtil.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/DeployUtil.java index d728344f0..8da22e0c4 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/DeployUtil.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/DeployUtil.java @@ -44,7 +44,7 @@ public final class DeployUtil { private final Encryptor bytesEncryptor; private final boolean useValidationNotNull; - public DeployUtil(TypeManager typeMgr, DatabaseBuilder config) { + public DeployUtil(TypeManager typeMgr, DatabaseBuilder.Settings config) { this.typeManager = typeMgr; this.namingConvention = config.getNamingConvention(); this.dbPlatform = config.getDatabasePlatform(); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/ReadAnnotationConfig.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/ReadAnnotationConfig.java index 2fd6d1e78..74268616b 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/ReadAnnotationConfig.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/ReadAnnotationConfig.java @@ -31,7 +31,7 @@ final class ReadAnnotationConfig { private final ReadValidationAnnotations jakartaValidation; private final Set> metaAnnotations = new HashSet<>(); - ReadAnnotationConfig(GeneratedPropertyFactory generatedPropFactory, String asOfViewSuffix, String versionsBetweenSuffix, DatabaseBuilder config) { + ReadAnnotationConfig(GeneratedPropertyFactory generatedPropFactory, String asOfViewSuffix, String versionsBetweenSuffix, DatabaseBuilder.Settings config) { this.generatedPropFactory = generatedPropFactory; this.asOfViewSuffix = asOfViewSuffix; this.versionsBetweenSuffix = versionsBetweenSuffix; diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/ReadAnnotations.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/ReadAnnotations.java index 5bb7ae54d..162d4cbb2 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/ReadAnnotations.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/ReadAnnotations.java @@ -12,7 +12,7 @@ public final class ReadAnnotations { private final ReadAnnotationConfig readConfig; - public ReadAnnotations(GeneratedPropertyFactory generatedPropFactory, String asOfViewSuffix, String versionsBetweenSuffix, DatabaseBuilder config) { + public ReadAnnotations(GeneratedPropertyFactory generatedPropFactory, String asOfViewSuffix, String versionsBetweenSuffix, DatabaseBuilder.Settings config) { this.readConfig = new ReadAnnotationConfig(generatedPropFactory, asOfViewSuffix, versionsBetweenSuffix, config); } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryEngine.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryEngine.java index 73a1d9a2d..969d7ca25 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryEngine.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryEngine.java @@ -38,7 +38,7 @@ public final class CQueryEngine { private final CQueryHistorySupport historySupport; private final DatabasePlatform dbPlatform; - public CQueryEngine(DatabaseBuilder config, DatabasePlatform dbPlatform, Binder binder, Map asOfTableMapping, Map draftTableMap) { + public CQueryEngine(DatabaseBuilder.Settings config, DatabasePlatform dbPlatform, Binder binder, Map asOfTableMapping, Map draftTableMap) { this.dbPlatform = dbPlatform; this.defaultFetchSizeFindEach = config.getJdbcFetchSizeFindEach(); this.defaultFetchSizeFindList = config.getJdbcFetchSizeFindList(); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/TransactionManagerOptions.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/TransactionManagerOptions.java index f94bbd345..ba6dc3967 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/TransactionManagerOptions.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/TransactionManagerOptions.java @@ -18,7 +18,7 @@ public final class TransactionManagerOptions { final SpiServer server; final boolean notifyL2CacheInForeground; - final DatabaseBuilder config; + final DatabaseBuilder.Settings config; final ClusterManager clusterManager; final BackgroundExecutor backgroundExecutor; @@ -33,8 +33,8 @@ public final class TransactionManagerOptions { final ClockService clockService; - public TransactionManagerOptions(SpiServer server, boolean notifyL2CacheInForeground, DatabaseBuilder config, TransactionScopeManager scopeManager, ClusterManager clusterManager, - BackgroundExecutor backgroundExecutor, DocStoreUpdateProcessor docStoreUpdateProcessor, + public TransactionManagerOptions(SpiServer server, boolean notifyL2CacheInForeground, DatabaseBuilder.Settings config, TransactionScopeManager scopeManager, + ClusterManager clusterManager, BackgroundExecutor backgroundExecutor, DocStoreUpdateProcessor docStoreUpdateProcessor, BeanDescriptorManager descMgr, DataSourceSupplier dataSourceSupplier, SpiProfileHandler profileHandler, SpiLogManager logManager, TableModState tableModState, ServerCacheNotify cacheNotify, ClockService clockService) { this.server = server; diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/type/DefaultTypeFactory.java b/ebean-core/src/main/java/io/ebeaninternal/server/type/DefaultTypeFactory.java index 881021efe..5b6e36be4 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/type/DefaultTypeFactory.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/type/DefaultTypeFactory.java @@ -16,9 +16,9 @@ import java.util.Date; */ final class DefaultTypeFactory { - private final DatabaseBuilder config; + private final DatabaseBuilder.Settings config; - public DefaultTypeFactory(DatabaseBuilder config) { + public DefaultTypeFactory(DatabaseBuilder.Settings config) { this.config = config; } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/type/DefaultTypeManager.java b/ebean-core/src/main/java/io/ebeaninternal/server/type/DefaultTypeManager.java index 4cc68f665..d781b2abc 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/type/DefaultTypeManager.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/type/DefaultTypeManager.java @@ -76,7 +76,7 @@ public final class DefaultTypeManager implements TypeManager { /** * Create the DefaultTypeManager. */ - public DefaultTypeManager(DatabaseBuilder config, BootupClasses bootupClasses) { + public DefaultTypeManager(DatabaseBuilder.Settings config, BootupClasses bootupClasses) { this.jsonDateTime = config.getJsonDateTime(); this.jsonDate = config.getJsonDate(); this.typeMap = new ConcurrentHashMap<>(); @@ -108,7 +108,7 @@ public final class DefaultTypeManager implements TypeManager { } } - private void loadGeoTypeBinder(DatabaseBuilder config) { + private void loadGeoTypeBinder(DatabaseBuilder.Settings config) { GeoTypeProvider provider = config.getServiceObject(GeoTypeProvider.class); if (provider == null) { provider = ServiceUtil.service(GeoTypeProvider.class); @@ -139,7 +139,7 @@ public final class DefaultTypeManager implements TypeManager { /** * Load custom scalar types registered via ExtraTypeFactory and ServiceLoader. */ - private void loadTypesFromProviders(DatabaseBuilder config, Object objectMapper) { + private void loadTypesFromProviders(DatabaseBuilder.Settings config, Object objectMapper) { for (ExtraTypeFactory plugin : ServiceLoader.load(ExtraTypeFactory.class)) { for (ScalarType type : plugin.createTypes(config, objectMapper)) { add(type); @@ -616,7 +616,7 @@ public final class DefaultTypeManager implements TypeManager { } - private Object initObjectMapper(DatabaseBuilder config) { + private Object initObjectMapper(DatabaseBuilder.Settings config) { Object objectMapper = config.getObjectMapper(); if (objectMapper == null) { objectMapper = InitObjectMapper.init(); @@ -674,7 +674,7 @@ public final class DefaultTypeManager implements TypeManager { } - private void initialiseJavaTimeTypes(DatabaseBuilder config) { + private void initialiseJavaTimeTypes(DatabaseBuilder.Settings config) { ZoneId zoneId = zoneId(config); typeMap.put(java.nio.file.Path.class, new ScalarTypePath()); @@ -702,7 +702,7 @@ public final class DefaultTypeManager implements TypeManager { addType(Duration.class, (durationNanos) ? new ScalarTypeDurationWithNanos() : new ScalarTypeDuration()); } - private ZoneId zoneId(DatabaseBuilder config) { + private ZoneId zoneId(DatabaseBuilder.Settings config) { final String dataTimeZone = config.getDataTimeZone(); return (dataTimeZone == null) ? ZoneOffset.systemDefault() : TimeZone.getTimeZone(dataTimeZone).toZoneId(); } @@ -716,7 +716,7 @@ public final class DefaultTypeManager implements TypeManager { * Register all the standard types supported. This is the standard JDBC types * plus some other common types such as java.util.Date and java.util.Calendar. */ - private void initialiseStandard(DatabaseBuilder config) { + private void initialiseStandard(DatabaseBuilder.Settings config) { DatabasePlatform databasePlatform = config.getDatabasePlatform(); int platformClobType = databasePlatform.clobDbType(); int platformBlobType = databasePlatform.blobDbType(); diff --git a/ebean-core/src/test/java/io/ebeaninternal/server/core/InitDataSourceTest.java b/ebean-core/src/test/java/io/ebeaninternal/server/core/InitDataSourceTest.java index 1a3f620ea..824477d43 100644 --- a/ebean-core/src/test/java/io/ebeaninternal/server/core/InitDataSourceTest.java +++ b/ebean-core/src/test/java/io/ebeaninternal/server/core/InitDataSourceTest.java @@ -19,12 +19,12 @@ import static org.junit.jupiter.api.Assertions.*; public class InitDataSourceTest { - private DatabaseBuilder newConfig(String readOnlyUrl) { + private DatabaseBuilder.Settings newConfig(String readOnlyUrl) { DatabaseBuilder config = new DatabaseConfig(); DataSourceConfig roConfig = new DataSourceConfig(); roConfig.setUrl(readOnlyUrl); config.setReadOnlyDataSourceConfig(roConfig); - return config; + return config.settings(); } @Test @@ -35,7 +35,7 @@ public class InitDataSourceTest { @Test public void readOnlyConfig_null_whenSetNullExplicitly() { - DatabaseBuilder config = new DatabaseConfig(); + DatabaseConfig config = new DatabaseConfig(); config.setReadOnlyDataSourceConfig(null); assertNull(new InitDataSource(config).readOnlyConfig()); @@ -57,7 +57,7 @@ public class InitDataSourceTest { @Test public void readOnlyConfig_when_autoReadOnlyDataSource() { - DatabaseBuilder config = new DatabaseConfig(); + DatabaseConfig config = new DatabaseConfig(); config.setAutoReadOnlyDataSource(true); assertNotNull(new InitDataSource(config).readOnlyConfig()); @@ -65,7 +65,7 @@ public class InitDataSourceTest { @Test public void readOnlyConfig_when_autoReadOnlyDataSource_expect_setToNull() { - DatabaseBuilder config = newConfig("none"); + var config = newConfig("none"); config.setAutoReadOnlyDataSource(true); final DataSourceBuilder readOnlyConfig = new InitDataSource(config).readOnlyConfig(); @@ -75,7 +75,7 @@ public class InitDataSourceTest { @Test public void readOnlyConfig_when_urlSet() { - DatabaseBuilder config = newConfig("foo"); + var config = newConfig("foo"); final DataSourceBuilder roConfig = new InitDataSource(config).readOnlyConfig(); assertNotNull(roConfig); @@ -84,7 +84,7 @@ public class InitDataSourceTest { @Test public void readOnlyConfig_when_readOnlyUrlSetOnMain() { - DatabaseBuilder config = newConfig(null); + var config = newConfig(null); // alternate location to set read-only url for developer convenience config.getDataSourceConfig().readOnlyUrl("bar"); @@ -95,7 +95,7 @@ public class InitDataSourceTest { @Test public void readOnlyConfig_when_readOnlyUrlSetOnMain_withNone() { - DatabaseBuilder config = newConfig("None"); + var config = newConfig("None"); // alternate location to set read-only url for developer convenience config.getDataSourceConfig().readOnlyUrl("bar"); @@ -106,7 +106,7 @@ public class InitDataSourceTest { @Test public void readOnlyConfig_when_bothReadOnlyUrlsSet() { - DatabaseBuilder config = newConfig("one"); + var config = newConfig("one"); config.getDataSourceConfig().readOnlyUrl("two"); final DataSourceBuilder roConfig = new InitDataSource(config).readOnlyConfig(); @@ -116,7 +116,7 @@ public class InitDataSourceTest { @Test public void readOnlyConfig_when_readOnlyUrlSetOnMain_withNoneNone() { - DatabaseBuilder config = newConfig("none"); + var config = newConfig("none"); // alternate location to set read-only url for developer convenience config.getDataSourceConfig().readOnlyUrl("none"); @@ -126,8 +126,8 @@ public class InitDataSourceTest { @Test public void readOnlyConfig_when_urlSet_2() { - DatabaseBuilder config = new DatabaseConfig(); - config.getReadOnlyDataSourceConfig().url("foo"); + DatabaseConfig config = new DatabaseConfig(); + config.settings().getReadOnlyDataSourceConfig().url("foo"); final DataSourceBuilder roConfig = new InitDataSource(config).readOnlyConfig(); assertNotNull(roConfig); @@ -136,7 +136,7 @@ public class InitDataSourceTest { @Test void isPostgresAllQuotedIdentifiers_true_when_postgres() { - DatabaseBuilder config = new DatabaseConfig(); + DatabaseConfig config = new DatabaseConfig(); config.setAllQuotedIdentifiers(true); config.setDatabasePlatform(new PostgresPlatform()); @@ -145,7 +145,7 @@ public class InitDataSourceTest { @Test void isPostgresAllQuotedIdentifiers_true_when_postgres9() { - DatabaseBuilder config = new DatabaseConfig(); + DatabaseConfig config = new DatabaseConfig(); config.setAllQuotedIdentifiers(true); config.setDatabasePlatform(new Postgres9Platform()); @@ -154,7 +154,7 @@ public class InitDataSourceTest { @Test void isPostgresAllQuotedIdentifiers_false() { - DatabaseBuilder config = new DatabaseConfig(); + DatabaseConfig config = new DatabaseConfig(); config.setAllQuotedIdentifiers(false); config.setDatabasePlatform(new PostgresPlatform()); @@ -163,7 +163,7 @@ public class InitDataSourceTest { @Test void isPostgresAllQuotedIdentifiers_false_when_notPostgres() { - DatabaseBuilder config = new DatabaseConfig(); + DatabaseConfig config = new DatabaseConfig(); config.setAllQuotedIdentifiers(true); config.setDatabasePlatform(new H2Platform()); @@ -172,7 +172,7 @@ public class InitDataSourceTest { @Test public void online() { - DatabaseBuilder config = new DatabaseConfig(); + DatabaseConfig config = new DatabaseConfig(); config.getDataSourceConfig().username("sa"); config.getDataSourceConfig().password(""); config.getDataSourceConfig().url("jdbc:h2:mem:dsTestOnline"); @@ -204,7 +204,7 @@ public class InitDataSourceTest { @Test public void offline() throws SQLException { - DatabaseBuilder config = new DatabaseConfig(); + DatabaseConfig config = new DatabaseConfig(); DataSourceBuilder dsConfig = config.getDataSourceConfig(); dsConfig.username("sa"); dsConfig.password(""); diff --git a/ebean-core/src/test/java/io/ebeaninternal/server/deploy/parse/AnnotationClassTest.java b/ebean-core/src/test/java/io/ebeaninternal/server/deploy/parse/AnnotationClassTest.java index 78a9e6b90..31ede238e 100644 --- a/ebean-core/src/test/java/io/ebeaninternal/server/deploy/parse/AnnotationClassTest.java +++ b/ebean-core/src/test/java/io/ebeaninternal/server/deploy/parse/AnnotationClassTest.java @@ -46,7 +46,7 @@ public class AnnotationClassTest { } @SuppressWarnings({"unchecked", "rawtypes"}) - private AnnotationClass createAnnotationClass(DatabaseBuilder config) { + private AnnotationClass createAnnotationClass(DatabaseBuilder.Settings config) { DeployUtil deployUtil = new DeployUtil(new DefaultTypeManager(config, new BootupClasses()), config); DeployBeanInfo deployBeanInfo = new DeployBeanInfo(deployUtil, new DeployBeanDescriptor<>(null, Customer.class, null)); @@ -54,9 +54,9 @@ public class AnnotationClassTest { return new AnnotationClass(deployBeanInfo, readAnnotationConfig); } - private DatabaseBuilder sqlServerPlatform(boolean allQuotedIdentifiers) { + private DatabaseBuilder.Settings sqlServerPlatform(boolean allQuotedIdentifiers) { SqlServer17Platform sqlServer17Platform = new SqlServer17Platform(); - DatabaseBuilder config = new DatabaseConfig(); + var config = new DatabaseConfig().settings(); config.setDatabasePlatform(sqlServer17Platform); config.setAllQuotedIdentifiers(allQuotedIdentifiers); diff --git a/ebean-core/src/test/java/io/ebeaninternal/server/type/DefaultTypeFactoryTest.java b/ebean-core/src/test/java/io/ebeaninternal/server/type/DefaultTypeFactoryTest.java index d5b83e7c8..07780136d 100644 --- a/ebean-core/src/test/java/io/ebeaninternal/server/type/DefaultTypeFactoryTest.java +++ b/ebean-core/src/test/java/io/ebeaninternal/server/type/DefaultTypeFactoryTest.java @@ -1,5 +1,6 @@ package io.ebeaninternal.server.type; +import io.ebean.config.DatabaseConfig; import io.ebean.core.type.ScalarType; import org.junit.jupiter.api.Test; @@ -10,7 +11,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; public class DefaultTypeFactoryTest { - DefaultTypeFactory defaultTypeFactory = new DefaultTypeFactory(null); + DefaultTypeFactory defaultTypeFactory = new DefaultTypeFactory(new DatabaseConfig()); @Test public void testCreateBoolean() throws Exception { diff --git a/ebean-core/src/test/java/io/ebeaninternal/server/type/DefaultTypeManagerTest.java b/ebean-core/src/test/java/io/ebeaninternal/server/type/DefaultTypeManagerTest.java index 68adea658..646275c95 100644 --- a/ebean-core/src/test/java/io/ebeaninternal/server/type/DefaultTypeManagerTest.java +++ b/ebean-core/src/test/java/io/ebeaninternal/server/type/DefaultTypeManagerTest.java @@ -21,7 +21,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; public class DefaultTypeManagerTest { private DefaultTypeManager create() { - DatabaseBuilder serverConfig = new DatabaseConfig(); + var serverConfig = new DatabaseConfig(); serverConfig.setDatabasePlatform(new PostgresPlatform()); BootupClasses bootupClasses = new BootupClasses(); return new DefaultTypeManager(serverConfig, bootupClasses); diff --git a/ebean-core/src/test/java/io/ebeaninternal/server/type/TestTypeManager.java b/ebean-core/src/test/java/io/ebeaninternal/server/type/TestTypeManager.java index b6c1e0bf2..3aa50c69b 100644 --- a/ebean-core/src/test/java/io/ebeaninternal/server/type/TestTypeManager.java +++ b/ebean-core/src/test/java/io/ebeaninternal/server/type/TestTypeManager.java @@ -122,7 +122,7 @@ class TestTypeManager extends BaseTest { } private DefaultTypeManager createTypeManager() { - DatabaseBuilder config = new DatabaseConfig(); + var config = new DatabaseConfig(); config.setDatabasePlatform(new H2Platform()); BootupClasses bootupClasses = new BootupClasses(); @@ -132,7 +132,7 @@ class TestTypeManager extends BaseTest { } private DefaultTypeManager createTypeManagerDefaultEnumTypeString() { - DatabaseBuilder config = new DatabaseConfig(); + var config = new DatabaseConfig(); config.setDatabasePlatform(new H2Platform()); config.setDefaultEnumType(EnumType.STRING); diff --git a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/DdlGenerator.java b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/DdlGenerator.java index bb2516e88..9fb81acf1 100644 --- a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/DdlGenerator.java +++ b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/DdlGenerator.java @@ -51,7 +51,7 @@ public class DdlGenerator implements SpiDdlGenerator { public DdlGenerator(SpiEbeanServer server) { this.server = server; - final DatabaseBuilder config = server.config(); + final var config = server.config(); this.jaxbPresent = Detect.isJAXBPresent(config); this.generateDdl = config.isDdlGenerate(); this.extraDdl = config.isDdlExtra(); @@ -318,7 +318,7 @@ public class DdlGenerator implements SpiDdlGenerator { /** * Create the ScriptTransform for placeholder key/value replacement. */ - private ScriptTransform createScriptTransform(DatabaseBuilder config) { + private ScriptTransform createScriptTransform(DatabaseBuilder.Settings config) { return ScriptTransform.build(config.getDdlPlaceholders(), config.getDdlPlaceholderMap()); } diff --git a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/DefaultDbMigration.java b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/DefaultDbMigration.java index 376aaa748..c44c6da5f 100644 --- a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/DefaultDbMigration.java +++ b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/DefaultDbMigration.java @@ -73,7 +73,7 @@ public class DefaultDbMigration implements DbMigration { protected DatabasePlatform databasePlatform; private boolean vanillaPlatform; protected List platforms = new ArrayList<>(); - protected DatabaseBuilder databaseBuilder; + protected DatabaseBuilder.Settings databaseBuilder; protected DbConstraintNaming constraintNaming; protected Boolean strictMode; protected Boolean includeGeneratedFileComment; @@ -114,7 +114,8 @@ public class DefaultDbMigration implements DbMigration { } @Override - public void setServerConfig(DatabaseBuilder config) { + public void setServerConfig(DatabaseBuilder builder) { + var config = builder.settings(); if (this.databaseBuilder == null) { this.databaseBuilder = config; } diff --git a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/Detect.java b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/Detect.java index 0f54abe15..7da655e23 100644 --- a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/Detect.java +++ b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/Detect.java @@ -10,7 +10,7 @@ public class Detect { /** * Return true if JAXB is present. */ - public static boolean isJAXBPresent(DatabaseBuilder config) { + public static boolean isJAXBPresent(DatabaseBuilder.Settings config) { return config.getClassLoadConfig().isPresent("jakarta.xml.bind.JAXBException"); } } diff --git a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/BaseDdlHandler.java b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/BaseDdlHandler.java index 618b5c56f..1b5404465 100644 --- a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/BaseDdlHandler.java +++ b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/BaseDdlHandler.java @@ -14,7 +14,7 @@ public class BaseDdlHandler implements DdlHandler { protected final TableDdl tableDdl; - public BaseDdlHandler(DatabaseBuilder config, PlatformDdl platformDdl) { + public BaseDdlHandler(DatabaseBuilder.Settings config, PlatformDdl platformDdl) { this(config, platformDdl, new BaseTableDdl(config, platformDdl)); } diff --git a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/BaseTableDdl.java b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/BaseTableDdl.java index 4ad068e34..07b6b0ade 100644 --- a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/BaseTableDdl.java +++ b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/BaseTableDdl.java @@ -155,7 +155,7 @@ public class BaseTableDdl implements TableDdl { /** * Construct with a naming convention and platform specific DDL. */ - public BaseTableDdl(DatabaseBuilder config, PlatformDdl platformDdl) { + public BaseTableDdl(DatabaseBuilder.Settings config, PlatformDdl platformDdl) { this.namingConvention = config.getNamingConvention(); this.naming = config.getConstraintNaming(); this.historyTableSuffix = config.getHistoryTableSuffix(); diff --git a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/ClickHouseDdl.java b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/ClickHouseDdl.java index d39f810d9..91a4d43bc 100644 --- a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/ClickHouseDdl.java +++ b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/ClickHouseDdl.java @@ -18,7 +18,7 @@ public class ClickHouseDdl extends PlatformDdl { } @Override - public DdlHandler createDdlHandler(DatabaseBuilder config) { + public DdlHandler createDdlHandler(DatabaseBuilder.Settings config) { return new ClickHouseDdlHandler(config, this); } diff --git a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/ClickHouseDdlHandler.java b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/ClickHouseDdlHandler.java index 813b17828..9d7bca961 100644 --- a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/ClickHouseDdlHandler.java +++ b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/ClickHouseDdlHandler.java @@ -5,7 +5,7 @@ import io.ebeaninternal.dbmigration.ddlgeneration.BaseDdlHandler; public class ClickHouseDdlHandler extends BaseDdlHandler { - public ClickHouseDdlHandler(DatabaseBuilder config, PlatformDdl platformDdl) { + public ClickHouseDdlHandler(DatabaseBuilder.Settings config, PlatformDdl platformDdl) { super(config, platformDdl, new ClickHouseTableDdl(config, platformDdl)); } } diff --git a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/ClickHouseTableDdl.java b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/ClickHouseTableDdl.java index 106c2626a..d3fcb2331 100644 --- a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/ClickHouseTableDdl.java +++ b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/ClickHouseTableDdl.java @@ -6,7 +6,7 @@ import io.ebeaninternal.dbmigration.migration.CreateTable; public class ClickHouseTableDdl extends BaseTableDdl { - public ClickHouseTableDdl(DatabaseBuilder config, PlatformDdl platformDdl) { + public ClickHouseTableDdl(DatabaseBuilder.Settings config, PlatformDdl platformDdl) { super(config, platformDdl); } diff --git a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/Db2HistoryDdl.java b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/Db2HistoryDdl.java index b005278ad..e03c4f3c1 100644 --- a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/Db2HistoryDdl.java +++ b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/Db2HistoryDdl.java @@ -20,7 +20,7 @@ public class Db2HistoryDdl extends DbTableBasedHistoryDdl implements PlatformHis private String transactionId; @Override - public void configure(DatabaseBuilder config, PlatformDdl platformDdl) { + public void configure(DatabaseBuilder.Settings config, PlatformDdl platformDdl) { super.configure(config, platformDdl); this.systemPeriodStart = config.getAsOfSysPeriod() + "_start"; this.systemPeriodEnd = config.getAsOfSysPeriod() + "_end"; diff --git a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/DbTableBasedHistoryDdl.java b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/DbTableBasedHistoryDdl.java index 6c584878e..2113319a9 100644 --- a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/DbTableBasedHistoryDdl.java +++ b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/DbTableBasedHistoryDdl.java @@ -16,7 +16,7 @@ public abstract class DbTableBasedHistoryDdl implements PlatformHistoryDdl.Table protected PlatformDdl platformDdl; @Override - public void configure(DatabaseBuilder config, PlatformDdl platformDdl) { + public void configure(DatabaseBuilder.Settings config, PlatformDdl platformDdl) { this.platformDdl = platformDdl; this.historySuffix = config.getHistoryTableSuffix(); this.constraintNaming = config.getConstraintNaming(); diff --git a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/DbTriggerBasedHistoryDdl.java b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/DbTriggerBasedHistoryDdl.java index eb85459a8..ab441a3f5 100644 --- a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/DbTriggerBasedHistoryDdl.java +++ b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/DbTriggerBasedHistoryDdl.java @@ -28,7 +28,7 @@ public abstract class DbTriggerBasedHistoryDdl extends DbTableBasedHistoryDdl im } @Override - public void configure(DatabaseBuilder config, PlatformDdl platformDdl) { + public void configure(DatabaseBuilder.Settings config, PlatformDdl platformDdl) { super.configure(config, platformDdl); this.sysPeriod = config.getAsOfSysPeriod(); this.viewSuffix = config.getAsOfViewSuffix(); diff --git a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/HanaHistoryDdl.java b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/HanaHistoryDdl.java index 38daedab2..8bf4284ba 100644 --- a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/HanaHistoryDdl.java +++ b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/HanaHistoryDdl.java @@ -17,7 +17,7 @@ public class HanaHistoryDdl extends DbTableBasedHistoryDdl implements PlatformHi private String systemPeriodEnd; @Override - public void configure(DatabaseBuilder config, PlatformDdl platformDdl) { + public void configure(DatabaseBuilder.Settings config, PlatformDdl platformDdl) { super.configure(config, platformDdl); this.systemPeriodStart = config.getAsOfSysPeriod() + "_start"; this.systemPeriodEnd = config.getAsOfSysPeriod() + "_end"; diff --git a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/MariaDbHistoryDdl.java b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/MariaDbHistoryDdl.java index 1faffeb64..6e65330b6 100644 --- a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/MariaDbHistoryDdl.java +++ b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/MariaDbHistoryDdl.java @@ -16,7 +16,7 @@ public class MariaDbHistoryDdl implements PlatformHistoryDdl { private PlatformDdl platformDdl; @Override - public void configure(DatabaseBuilder config, PlatformDdl platformDdl) { + public void configure(DatabaseBuilder.Settings config, PlatformDdl platformDdl) { this.platformDdl = platformDdl; } diff --git a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/NoHistorySupportDdl.java b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/NoHistorySupportDdl.java index 10d08718f..8400af8dc 100644 --- a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/NoHistorySupportDdl.java +++ b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/NoHistorySupportDdl.java @@ -13,7 +13,7 @@ import io.ebeaninternal.dbmigration.model.MTable; public class NoHistorySupportDdl implements PlatformHistoryDdl { @Override - public void configure(DatabaseBuilder config, PlatformDdl platformDdl) { + public void configure(DatabaseBuilder.Settings config, PlatformDdl platformDdl) { // does nothing } diff --git a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl.java b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl.java index 9efc25123..a11d2a12e 100644 --- a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl.java +++ b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl.java @@ -105,7 +105,7 @@ public class PlatformDdl { /** * Set configuration options. */ - public void configure(DatabaseBuilder config) { + public void configure(DatabaseBuilder.Settings config) { historyDdl.configure(config, this); naming = config.getConstraintNaming(); } @@ -113,7 +113,7 @@ public class PlatformDdl { /** * Create a DdlHandler for the specific database platform. */ - public DdlHandler createDdlHandler(DatabaseBuilder config) { + public DdlHandler createDdlHandler(DatabaseBuilder.Settings config) { return new BaseDdlHandler(config, this); } diff --git a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformHistoryDdl.java b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformHistoryDdl.java index 41f62ec76..a07224342 100644 --- a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformHistoryDdl.java +++ b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformHistoryDdl.java @@ -14,7 +14,7 @@ public interface PlatformHistoryDdl { /** * Configure typically reading the necessary parameters from DatabaseConfig and Platform. */ - void configure(DatabaseBuilder config, PlatformDdl platformDdl); + void configure(DatabaseBuilder.Settings config, PlatformDdl platformDdl); /** * Creates a new table and add history support to the table using platform specific mechanism. diff --git a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/SqlServerHistoryDdl.java b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/SqlServerHistoryDdl.java index a0b1519cb..88eb895e6 100644 --- a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/SqlServerHistoryDdl.java +++ b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/SqlServerHistoryDdl.java @@ -22,7 +22,7 @@ public class SqlServerHistoryDdl implements PlatformHistoryDdl { protected String historySuffix; @Override - public void configure(DatabaseBuilder config, PlatformDdl platformDdl) { + public void configure(DatabaseBuilder.Settings config, PlatformDdl platformDdl) { this.systemPeriodStart = config.getAsOfSysPeriod() + "From"; this.systemPeriodEnd = config.getAsOfSysPeriod() + "To"; this.platformDdl = platformDdl; diff --git a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/model/PlatformDdlWriter.java b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/model/PlatformDdlWriter.java index c0938701a..02b90c9a2 100644 --- a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/model/PlatformDdlWriter.java +++ b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/model/PlatformDdlWriter.java @@ -26,13 +26,13 @@ public class PlatformDdlWriter { private static final System.Logger logger = AppLog.getLogger(PlatformDdlWriter.class); - private final DatabaseBuilder databaseBuilder; + private final DatabaseBuilder.Settings config; private final PlatformDdl platformDdl; private final int lockTimeoutSeconds; - public PlatformDdlWriter(DatabasePlatform platform, DatabaseBuilder dbConfig, int lockTimeoutSeconds) { + public PlatformDdlWriter(DatabasePlatform platform, DatabaseBuilder.Settings config, int lockTimeoutSeconds) { this.platformDdl = PlatformDdlBuilder.create(platform); - this.databaseBuilder = dbConfig; + this.config = config; this.lockTimeoutSeconds = lockTimeoutSeconds; } @@ -87,7 +87,7 @@ public class PlatformDdlWriter { * Write the 'Apply' DDL buffers to the writer. */ protected void writeApplyDdl(Writer writer, DdlWrite ddl) throws IOException { - String header = databaseBuilder.getDdlHeader(); + String header = config.getDdlHeader(); if (header != null && !header.isEmpty()) { writer.append(header).append('\n'); } @@ -98,7 +98,7 @@ public class PlatformDdlWriter { * Return the platform specific DdlHandler (to generate DDL). */ protected DdlHandler handler() { - return platformDdl.createDdlHandler(databaseBuilder); + return platformDdl.createDdlHandler(config); } /** diff --git a/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/BaseDdlHandlerTest.java b/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/BaseDdlHandlerTest.java index d90b1d14e..7266ed90c 100644 --- a/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/BaseDdlHandlerTest.java +++ b/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/BaseDdlHandlerTest.java @@ -22,7 +22,7 @@ public class BaseDdlHandlerTest extends BaseTestCase { private static boolean useV1Syntax = Boolean.getBoolean("ebean.h2.useV1Syntax"); - private final DatabaseBuilder serverConfig = new DatabaseConfig(); + private final DatabaseConfig serverConfig = new DatabaseConfig(); private DdlHandler handler(DatabasePlatform platform) { return PlatformDdlBuilder.create(platform).createDdlHandler(serverConfig); diff --git a/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/BaseTableDdlTest.java b/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/BaseTableDdlTest.java index dc63608af..f6d42cb29 100644 --- a/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/BaseTableDdlTest.java +++ b/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/BaseTableDdlTest.java @@ -20,7 +20,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; class BaseTableDdlTest { - private final DatabaseBuilder serverConfig = new DatabaseConfig(); + private final DatabaseConfig serverConfig = new DatabaseConfig(); private final PlatformDdl h2ddl = PlatformDdlBuilder.create(new H2Platform()); @Test diff --git a/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl_AlterColumnTest.java b/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl_AlterColumnTest.java index 733368700..52ca8e96e 100644 --- a/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl_AlterColumnTest.java +++ b/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl_AlterColumnTest.java @@ -36,7 +36,7 @@ public class PlatformDdl_AlterColumnTest { private final SoftAssertions softly = new SoftAssertions(); { - DatabaseBuilder serverConfig = DB.getDefault().pluginApi().config(); + DatabaseBuilder.Settings serverConfig = DB.getDefault().pluginApi().config(); sqlServerDdl.configure(serverConfig); } diff --git a/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl_CreateIndexTest.java b/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl_CreateIndexTest.java index 9c7c55c7d..0b26df48a 100644 --- a/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl_CreateIndexTest.java +++ b/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl_CreateIndexTest.java @@ -27,7 +27,7 @@ public class PlatformDdl_CreateIndexTest { private final PlatformDdl db2LuwDdl = PlatformDdlBuilder.create(new DB2LuwPlatform()); { - DatabaseBuilder config = DB.getDefault().pluginApi().config(); + DatabaseBuilder.Settings config = DB.getDefault().pluginApi().config(); h2Ddl.configure(config); pgDdl.configure(config); mysqlDdl.configure(config); @@ -38,7 +38,6 @@ public class PlatformDdl_CreateIndexTest { } WriteCreateIndex writeCreateIndex() { - return writeCreateIndex(true, true); } diff --git a/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl_dropUniqueConstraintTest.java b/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl_dropUniqueConstraintTest.java index 35e012a5f..75a5b7430 100644 --- a/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl_dropUniqueConstraintTest.java +++ b/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PlatformDdl_dropUniqueConstraintTest.java @@ -49,7 +49,7 @@ public class PlatformDdl_dropUniqueConstraintTest { sql = mysqlDdl.alterTableDropUniqueConstraint("mytab", "uq_name"); assertEquals("alter table mytab drop index uq_name", sql); - DatabaseBuilder config = new DatabaseConfig(); + DatabaseConfig config = new DatabaseConfig(); hanaDdl.configure(config); sql = hanaDdl.alterTableDropUniqueConstraint("mytab", "uq_name"); assertEquals("delimiter $$\n" + diff --git a/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/model/build/ModelBuildBeanVisitorTest.java b/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/model/build/ModelBuildBeanVisitorTest.java index 51fbf6605..53a8a6038 100644 --- a/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/model/build/ModelBuildBeanVisitorTest.java +++ b/ebean-ddl-generator/src/test/java/io/ebeaninternal/dbmigration/model/build/ModelBuildBeanVisitorTest.java @@ -55,7 +55,7 @@ public class ModelBuildBeanVisitorTest extends BaseTestCase { ModelContainer model = new ModelContainer(); - DatabaseBuilder config = new DatabaseConfig(); + DatabaseConfig config = new DatabaseConfig(); config.setName("h2"); config.loadFromProperties(); config.setName("h2other"); diff --git a/ebean-postgis-types/src/main/java/io/ebean/postgis/PostgisExtraTypeFactory.java b/ebean-postgis-types/src/main/java/io/ebean/postgis/PostgisExtraTypeFactory.java index 1630f968c..67c3cc7df 100644 --- a/ebean-postgis-types/src/main/java/io/ebean/postgis/PostgisExtraTypeFactory.java +++ b/ebean-postgis-types/src/main/java/io/ebean/postgis/PostgisExtraTypeFactory.java @@ -16,7 +16,7 @@ import java.util.List; public class PostgisExtraTypeFactory implements ExtraTypeFactory { @Override - public List> createTypes(DatabaseBuilder config, Object objectMapper) { + public List> createTypes(DatabaseBuilder.Settings config, Object objectMapper) { List> list = new ArrayList<>(); list.add(new ScalarTypePgisPoint()); diff --git a/ebean-postgis-types/src/main/java/io/ebean/postgis/PostgisGeoTypeBindProvider.java b/ebean-postgis-types/src/main/java/io/ebean/postgis/PostgisGeoTypeBindProvider.java index ab151db1d..2b4bbd7a1 100644 --- a/ebean-postgis-types/src/main/java/io/ebean/postgis/PostgisGeoTypeBindProvider.java +++ b/ebean-postgis-types/src/main/java/io/ebean/postgis/PostgisGeoTypeBindProvider.java @@ -7,7 +7,7 @@ import io.ebeaninternal.server.type.GeoTypeBinder; public class PostgisGeoTypeBindProvider implements GeoTypeProvider { @Override - public GeoTypeBinder createBinder(DatabaseBuilder config) { + public GeoTypeBinder createBinder(DatabaseBuilder.Settings config) { boolean withGeolatte = config.getClassLoadConfig().isPresent("org.geolatte.geom.Geometry"); return new PostgisGeoTypeBinder(withGeolatte); } diff --git a/ebean-redis/src/main/java/io/ebean/redis/RedisCacheFactory.java b/ebean-redis/src/main/java/io/ebean/redis/RedisCacheFactory.java index 6eda94bbd..e92676b89 100644 --- a/ebean-redis/src/main/java/io/ebean/redis/RedisCacheFactory.java +++ b/ebean-redis/src/main/java/io/ebean/redis/RedisCacheFactory.java @@ -74,7 +74,7 @@ final class RedisCacheFactory implements ServerCacheFactory { private final ReentrantLock lock = new ReentrantLock(); private ServerCacheNotify listener; - RedisCacheFactory(DatabaseBuilder config, BackgroundExecutor executor) { + RedisCacheFactory(DatabaseBuilder.Settings config, BackgroundExecutor executor) { this.executor = executor; this.nearCacheNotify = new DNearCacheNotify(); MetricFactory factory = MetricFactory.get(); @@ -95,7 +95,7 @@ final class RedisCacheFactory implements ServerCacheFactory { /** * Return the JedisPool to use (only 1 at this stage). */ - private JedisPool getJedisPool(DatabaseBuilder config) { + private JedisPool getJedisPool(DatabaseBuilder.Settings config) { JedisPool jedisPool = config.getServiceObject(JedisPool.class); if (jedisPool != null) { return jedisPool; diff --git a/ebean-redis/src/main/java/io/ebean/redis/RedisCachePlugin.java b/ebean-redis/src/main/java/io/ebean/redis/RedisCachePlugin.java index 1edea4674..e2fcc6fc7 100644 --- a/ebean-redis/src/main/java/io/ebean/redis/RedisCachePlugin.java +++ b/ebean-redis/src/main/java/io/ebean/redis/RedisCachePlugin.java @@ -12,6 +12,6 @@ public class RedisCachePlugin implements ServerCachePlugin { */ @Override public ServerCacheFactory create(DatabaseBuilder config, BackgroundExecutor executor) { - return new RedisCacheFactory(config, executor); + return new RedisCacheFactory(config.settings(), executor); } } diff --git a/ebean-test/pom.xml b/ebean-test/pom.xml index ab056e9c0..b5b3ab1ef 100644 --- a/ebean-test/pom.xml +++ b/ebean-test/pom.xml @@ -135,14 +135,14 @@ io.ebean ebean-joda-time - 13.24.0-RC1 + 13.24.0-RC2 test io.ebean ebean-jackson-jsonnode - 13.24.0-RC1 + 13.24.0-RC2 test diff --git a/ebean-test/src/main/java/io/ebean/test/config/AutoConfigureForTesting.java b/ebean-test/src/main/java/io/ebean/test/config/AutoConfigureForTesting.java index 3ff4c5113..668eb86bf 100644 --- a/ebean-test/src/main/java/io/ebean/test/config/AutoConfigureForTesting.java +++ b/ebean-test/src/main/java/io/ebean/test/config/AutoConfigureForTesting.java @@ -31,7 +31,8 @@ public class AutoConfigureForTesting implements AutoConfigure { private final String environmentDb = System.getProperty("db"); @Override - public void preConfigure(DatabaseBuilder config) { + public void preConfigure(DatabaseBuilder builder) { + var config = builder.settings(); Properties properties = config.getProperties(); if (properties != null) { // trigger determination of docker.host system property if not already done @@ -55,7 +56,8 @@ public class AutoConfigureForTesting implements AutoConfigure { } @Override - public void postConfigure(DatabaseBuilder config) { + public void postConfigure(DatabaseBuilder builder) { + var config = builder.settings(); if (!config.isDefaultServer()) { return; } @@ -87,7 +89,7 @@ public class AutoConfigureForTesting implements AutoConfigure { /** * Check if this is not the primary server and return true if that is the case. */ - private boolean isExtraServer(DatabaseBuilder config, Properties properties) { + private boolean isExtraServer(DatabaseBuilder.Settings config, Properties properties) { String extraDb = properties.getProperty("ebean.test.extraDb.dbName", properties.getProperty("ebean.test.extraDb")); if (extraDb != null && extraDb.equals(config.getName())) { config.setDefaultServer(false); @@ -99,7 +101,7 @@ public class AutoConfigureForTesting implements AutoConfigure { /** * Setup the DataSource on the extra database if necessary. */ - private void setupExtraDataSourceIfNecessary(DatabaseBuilder config) { + private void setupExtraDataSourceIfNecessary(DatabaseBuilder.Settings config) { DataSourceBuilder dataSourceConfig = config.getDataSourceConfig(); if (dataSourceConfig == null || dataSourceConfig.settings().getUsername() == null) { new PlatformAutoConfig(environmentDb, config) @@ -110,14 +112,14 @@ public class AutoConfigureForTesting implements AutoConfigure { /** * Setup support for Who, Multi-Tenant and DB encryption if they are not already set. */ - private void setupProviders(DatabaseBuilder config) { + private void setupProviders(DatabaseBuilder.Settings config) { new ProviderAutoConfig(config).run(); } /** * Setup the platform for testing including docker as needed and adjusting datasource config as needed. */ - private void setupPlatform(String db, DatabaseBuilder config) { + private void setupPlatform(String db, DatabaseBuilder.Settings config) { new PlatformAutoConfig(db, config).run(); } } diff --git a/ebean-test/src/main/java/io/ebean/test/config/platform/Config.java b/ebean-test/src/main/java/io/ebean/test/config/platform/Config.java index 67feefc14..3c8488798 100644 --- a/ebean-test/src/main/java/io/ebean/test/config/platform/Config.java +++ b/ebean-test/src/main/java/io/ebean/test/config/platform/Config.java @@ -37,11 +37,11 @@ class Config { private String schema; private String username; private String password; - private final DatabaseBuilder config; + private final DatabaseBuilder.Settings config; private boolean containerDropCreate; private final Properties dockerProperties = new Properties(); - Config(String db, String platform, String databaseName, DatabaseBuilder config) { + Config(String db, String platform, String databaseName, DatabaseBuilder.Settings config) { this.db = db; this.platform = platform; this.dockerPlatform = platform; diff --git a/ebean-test/src/main/java/io/ebean/test/config/platform/PlatformAutoConfig.java b/ebean-test/src/main/java/io/ebean/test/config/platform/PlatformAutoConfig.java index aa2d84710..8ef841025 100644 --- a/ebean-test/src/main/java/io/ebean/test/config/platform/PlatformAutoConfig.java +++ b/ebean-test/src/main/java/io/ebean/test/config/platform/PlatformAutoConfig.java @@ -38,14 +38,14 @@ public class PlatformAutoConfig { KNOWN_PLATFORMS.put("yugabyte", new YugabyteSetup()); } - private final DatabaseBuilder config; + private final DatabaseBuilder.Settings config; private final Properties properties; private String db; private String platform; private PlatformSetup platformSetup; private String databaseName; - public PlatformAutoConfig(String db, DatabaseBuilder config) { + public PlatformAutoConfig(String db, DatabaseBuilder.Settings config) { this.db = db; this.config = config; this.properties = config.getProperties(); diff --git a/ebean-test/src/main/java/io/ebean/test/config/provider/ProviderAutoConfig.java b/ebean-test/src/main/java/io/ebean/test/config/provider/ProviderAutoConfig.java index c5658f229..2c2983436 100644 --- a/ebean-test/src/main/java/io/ebean/test/config/provider/ProviderAutoConfig.java +++ b/ebean-test/src/main/java/io/ebean/test/config/provider/ProviderAutoConfig.java @@ -16,10 +16,10 @@ public class ProviderAutoConfig { private static final System.Logger log = AppLog.getLogger("io.ebean.test"); - private final DatabaseBuilder config; + private final DatabaseBuilder.Settings config; private final Properties properties; - public ProviderAutoConfig(DatabaseBuilder config) { + public ProviderAutoConfig(DatabaseBuilder.Settings config) { this.config = config; this.properties = config.getProperties(); } diff --git a/ebean-test/src/test/java/io/ebean/test/config/platform/ConfigTest.java b/ebean-test/src/test/java/io/ebean/test/config/platform/ConfigTest.java index 168629694..94ed1a9bb 100644 --- a/ebean-test/src/test/java/io/ebean/test/config/platform/ConfigTest.java +++ b/ebean-test/src/test/java/io/ebean/test/config/platform/ConfigTest.java @@ -38,7 +38,7 @@ class ConfigTest { @Test void extensions_whenNoSetValues() { - DatabaseBuilder databaseBuilder = new DatabaseConfig(); + DatabaseConfig databaseBuilder = new DatabaseConfig(); databaseBuilder.loadFromProperties(new Properties()); Config config = new Config("db", "postgis", "db", databaseBuilder); @@ -56,7 +56,7 @@ class ConfigTest { @Test void extensions_whenSetValues() { - DatabaseBuilder databaseBuilder = new DatabaseConfig(); + DatabaseConfig databaseBuilder = new DatabaseConfig(); Properties properties = new Properties(); properties.setProperty("ebean.test.extensions", "x,y"); properties.setProperty("ebean.test.extraDb.extensions", "z"); @@ -78,7 +78,7 @@ class ConfigTest { Properties p = new Properties(); p.setProperty("ebean.test.extraDb", "other"); - DatabaseBuilder serverConfig = new DatabaseConfig(); + DatabaseConfig serverConfig = new DatabaseConfig(); serverConfig.loadFromProperties(p); Config config = new Config("other", "postgres", "other", serverConfig); @@ -100,7 +100,7 @@ class ConfigTest { Properties p = new Properties(); p.setProperty("ebean.test.extraDb.dbName", "other"); - DatabaseBuilder serverConfig = new DatabaseConfig(); + DatabaseConfig serverConfig = new DatabaseConfig(); serverConfig.loadFromProperties(p); Config config = new Config("other", "postgres", "other", serverConfig); @@ -126,7 +126,7 @@ class ConfigTest { p.setProperty("ebean.test.extraDb.password", "other_pwd"); p.setProperty("ebean.test.extraDb.url", "other_url"); - DatabaseBuilder serverConfig = new DatabaseConfig(); + DatabaseConfig serverConfig = new DatabaseConfig(); serverConfig.setName("scOther"); serverConfig.loadFromProperties(p); @@ -151,7 +151,7 @@ class ConfigTest { sourceProperties.setProperty("ebean.test.dbName", "main"); sourceProperties.setProperty("ebean.test.extraDb.dbName", "central"); - DatabaseBuilder serverConfig = new DatabaseConfig(); + DatabaseConfig serverConfig = new DatabaseConfig(); serverConfig.setName("main"); serverConfig.loadFromProperties(sourceProperties); @@ -220,7 +220,7 @@ class ConfigTest { } private Config createConfig(Properties p) { - DatabaseBuilder serverConfig = new DatabaseConfig(); + DatabaseConfig serverConfig = new DatabaseConfig(); serverConfig.setName("scOther"); serverConfig.loadFromProperties(p); return new Config("db_name", "postgres", "db_name", serverConfig); diff --git a/ebean-test/src/test/java/io/ebean/xtest/config/DbMigrationConfigTest.java b/ebean-test/src/test/java/io/ebean/xtest/config/DbMigrationConfigTest.java index 06b885191..34c7c3713 100644 --- a/ebean-test/src/test/java/io/ebean/xtest/config/DbMigrationConfigTest.java +++ b/ebean-test/src/test/java/io/ebean/xtest/config/DbMigrationConfigTest.java @@ -16,7 +16,7 @@ public class DbMigrationConfigTest { @Test public void testLoad() { - DatabaseBuilder config = new DatabaseConfig(); + DatabaseConfig config = new DatabaseConfig(); config.setName("h2other"); config.loadFromProperties(); config.setDefaultServer(false); diff --git a/ebean-test/src/test/java/io/ebean/xtest/config/PlatformNoGeneratedKeysTest.java b/ebean-test/src/test/java/io/ebean/xtest/config/PlatformNoGeneratedKeysTest.java index 34afc8256..db3c9622b 100644 --- a/ebean-test/src/test/java/io/ebean/xtest/config/PlatformNoGeneratedKeysTest.java +++ b/ebean-test/src/test/java/io/ebean/xtest/config/PlatformNoGeneratedKeysTest.java @@ -89,7 +89,7 @@ public class PlatformNoGeneratedKeysTest { private static Database testH2Server() { - DatabaseBuilder config = new DatabaseConfig(); + DatabaseConfig config = new DatabaseConfig(); config.setName("h2_noGeneratedKeys"); OtherH2Platform platform = new OtherH2Platform(); diff --git a/ebean-test/src/test/java/io/ebean/xtest/dbmigration/DbMigrationGenerateTest.java b/ebean-test/src/test/java/io/ebean/xtest/dbmigration/DbMigrationGenerateTest.java index 8b387a8da..6d19a976b 100644 --- a/ebean-test/src/test/java/io/ebean/xtest/dbmigration/DbMigrationGenerateTest.java +++ b/ebean-test/src/test/java/io/ebean/xtest/dbmigration/DbMigrationGenerateTest.java @@ -89,7 +89,7 @@ public class DbMigrationGenerateTest { migration.addPlatform(Platform.YUGABYTE); - DatabaseBuilder config = new DatabaseConfig(); + DatabaseConfig config = new DatabaseConfig(); config.setName("migrationtest"); config.loadFromProperties(); config.setRegister(false); diff --git a/ebean-test/src/test/java/io/ebean/xtest/event/BeanFindControllerTest.java b/ebean-test/src/test/java/io/ebean/xtest/event/BeanFindControllerTest.java index 8032a4f7e..03e9518a7 100644 --- a/ebean-test/src/test/java/io/ebean/xtest/event/BeanFindControllerTest.java +++ b/ebean-test/src/test/java/io/ebean/xtest/event/BeanFindControllerTest.java @@ -27,7 +27,7 @@ public class BeanFindControllerTest extends BaseTestCase { @Test public void test() { - DatabaseBuilder config = new DatabaseConfig(); + var config = new DatabaseConfig(); config.setName("h2otherfind"); config.loadFromProperties(); @@ -170,7 +170,7 @@ public class BeanFindControllerTest extends BaseTestCase { } private Database prepareSoftRefs() { - DatabaseBuilder config = new DatabaseConfig(); + DatabaseConfig config = new DatabaseConfig(); config.setName("h2otherfind"); config.loadFromProperties(); diff --git a/ebean-test/src/test/java/io/ebean/xtest/internal/api/TDSpiEbeanServer.java b/ebean-test/src/test/java/io/ebean/xtest/internal/api/TDSpiEbeanServer.java index c44de8899..184ef9009 100644 --- a/ebean-test/src/test/java/io/ebean/xtest/internal/api/TDSpiEbeanServer.java +++ b/ebean-test/src/test/java/io/ebean/xtest/internal/api/TDSpiEbeanServer.java @@ -126,7 +126,7 @@ public class TDSpiEbeanServer extends TDSpiServer implements SpiEbeanServer { } @Override - public DatabaseBuilder config() { + public DatabaseBuilder.Settings config() { return null; } diff --git a/ebean-test/src/test/java/io/ebean/xtest/internal/api/TDSpiServer.java b/ebean-test/src/test/java/io/ebean/xtest/internal/api/TDSpiServer.java index 301b2aa0f..6efedcacb 100644 --- a/ebean-test/src/test/java/io/ebean/xtest/internal/api/TDSpiServer.java +++ b/ebean-test/src/test/java/io/ebean/xtest/internal/api/TDSpiServer.java @@ -579,7 +579,7 @@ public class TDSpiServer implements SpiServer { } @Override - public DatabaseBuilder config() { + public DatabaseBuilder.Settings config() { return null; } diff --git a/ebean-test/src/test/java/io/ebean/xtest/internal/server/text/json/DJsonScalarTest.java b/ebean-test/src/test/java/io/ebean/xtest/internal/server/text/json/DJsonScalarTest.java index 295bdcd4b..e39ee30db 100644 --- a/ebean-test/src/test/java/io/ebean/xtest/internal/server/text/json/DJsonScalarTest.java +++ b/ebean-test/src/test/java/io/ebean/xtest/internal/server/text/json/DJsonScalarTest.java @@ -24,7 +24,7 @@ public class DJsonScalarTest { private final DJsonScalar jsonScalar; public DJsonScalarTest() { - DatabaseBuilder serverConfig = new DatabaseConfig(); + var serverConfig = new DatabaseConfig(); serverConfig.setDatabasePlatform(new H2Platform()); DefaultTypeManager typeManager = new DefaultTypeManager(serverConfig, new BootupClasses()); jsonScalar = new DJsonScalar(typeManager); diff --git a/ebean-test/src/test/java/org/tests/basic/TestPersistenceContext.java b/ebean-test/src/test/java/org/tests/basic/TestPersistenceContext.java index cc18f4a95..a41255450 100644 --- a/ebean-test/src/test/java/org/tests/basic/TestPersistenceContext.java +++ b/ebean-test/src/test/java/org/tests/basic/TestPersistenceContext.java @@ -258,7 +258,7 @@ public class TestPersistenceContext extends BaseTestCase { @Test @Disabled void initDb() { - DatabaseBuilder config = new DatabaseConfig(); + DatabaseConfig config = new DatabaseConfig(); config.setName("h2-batch"); config.loadFromProperties(); config.setDdlExtra(false); @@ -292,7 +292,7 @@ public class TestPersistenceContext extends BaseTestCase { @Test @Disabled void testFindEachFindList() { - DatabaseBuilder config = new DatabaseConfig(); + DatabaseConfig config = new DatabaseConfig(); config.setName("h2-batch"); config.loadFromProperties(); config.setDdlRun(false); diff --git a/ebean-test/src/test/java/org/tests/basic/TestPersistenceContextMany.java b/ebean-test/src/test/java/org/tests/basic/TestPersistenceContextMany.java index 8fd251873..cf91280b7 100644 --- a/ebean-test/src/test/java/org/tests/basic/TestPersistenceContextMany.java +++ b/ebean-test/src/test/java/org/tests/basic/TestPersistenceContextMany.java @@ -98,7 +98,7 @@ public class TestPersistenceContextMany extends BaseTestCase { @Test @Disabled void initDb() { - DatabaseBuilder config = new DatabaseConfig(); + DatabaseConfig config = new DatabaseConfig(); config.setName("h2-batch"); config.loadFromProperties(); config.setDdlExtra(false); @@ -142,7 +142,7 @@ public class TestPersistenceContextMany extends BaseTestCase { @Test @Disabled void testFindEachFindList() { - DatabaseBuilder config = new DatabaseConfig(); + DatabaseConfig config = new DatabaseConfig(); config.setName("h2-batch"); config.loadFromProperties(); config.setDdlRun(false); diff --git a/ebean-test/src/test/java/org/tests/json/TestJsonSourceDefault.java b/ebean-test/src/test/java/org/tests/json/TestJsonSourceDefault.java index daaa7c70e..91d83fd14 100644 --- a/ebean-test/src/test/java/org/tests/json/TestJsonSourceDefault.java +++ b/ebean-test/src/test/java/org/tests/json/TestJsonSourceDefault.java @@ -23,7 +23,7 @@ class TestJsonSourceDefault { @ForPlatform(Platform.H2) @Disabled void testDirtyValues_diffSource() { - DatabaseBuilder config = new DatabaseConfig(); + DatabaseConfig config = new DatabaseConfig(); config.getDataSourceConfig() .setUsername("sa") .setPassword("") diff --git a/platforms/sqlserver/src/test/java/io/ebean/platform/sqlserver/SqlServerPlatformTest.java b/platforms/sqlserver/src/test/java/io/ebean/platform/sqlserver/SqlServerPlatformTest.java index 7277c226b..2726b575f 100644 --- a/platforms/sqlserver/src/test/java/io/ebean/platform/sqlserver/SqlServerPlatformTest.java +++ b/platforms/sqlserver/src/test/java/io/ebean/platform/sqlserver/SqlServerPlatformTest.java @@ -12,7 +12,7 @@ class SqlServerPlatformTest { @Test public void convertQuotedIdentifiers_when_allQuotedIdentifier_sqlServer() { - DatabaseBuilder config = new DatabaseConfig(); + DatabaseConfig config = new DatabaseConfig(); config.setAllQuotedIdentifiers(true); config.setNamingConvention(new MatchingNamingConvention()); @@ -26,7 +26,7 @@ class SqlServerPlatformTest { @Test public void convertQuotedIdentifiers() { - DatabaseBuilder config = new DatabaseConfig(); + DatabaseConfig config = new DatabaseConfig(); SqlServer17Platform dbPlatform = new SqlServer17Platform(); dbPlatform.configure(config.getPlatformConfig()); From 314e0a14b873d160e599b4b1794a8831b252263d Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Fri, 3 Nov 2023 23:00:29 +1300 Subject: [PATCH 3/6] Move the internal serviceObjectKey() methods back into DatabaseConfig They were incorrectly extracted to the interface as default methods --- ebean-api/src/main/java/io/ebean/DatabaseBuilder.java | 9 --------- .../src/main/java/io/ebean/config/DatabaseConfig.java | 11 ++++++++++- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ebean-api/src/main/java/io/ebean/DatabaseBuilder.java b/ebean-api/src/main/java/io/ebean/DatabaseBuilder.java index cf70dd01e..e69bcc100 100644 --- a/ebean-api/src/main/java/io/ebean/DatabaseBuilder.java +++ b/ebean-api/src/main/java/io/ebean/DatabaseBuilder.java @@ -79,15 +79,6 @@ public interface DatabaseBuilder { */ void putServiceObject(Object configObject); - default String serviceObjectKey(Object configObject) { - return serviceObjectKey(configObject.getClass()); - } - - default String serviceObjectKey(Class cls) { - String simpleName = cls.getSimpleName(); - return Character.toLowerCase(simpleName.charAt(0)) + simpleName.substring(1); - } - /** * Set the Jackson JsonFactory to use. *

    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 0b614f2e5..8d9e4c03e 100644 --- a/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java +++ b/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java @@ -386,7 +386,7 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { * Note: It is possible that multiple servers are sharing the same state file as * long as they are in the same JVM/ClassLoader scope. In this case it is * recommended to use the same uuidNodeId configuration. - * + *

    * If you have multiple servers in different JVMs, do not share the state * files! */ @@ -610,6 +610,15 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { return (P) serviceObject.get(serviceObjectKey(cls)); } + private String serviceObjectKey(Object configObject) { + return serviceObjectKey(configObject.getClass()); + } + + private String serviceObjectKey(Class cls) { + String simpleName = cls.getSimpleName(); + return Character.toLowerCase(simpleName.charAt(0)) + simpleName.substring(1); + } + @Override public JsonFactory getJsonFactory() { return jsonFactory; From e2d666df35cf6e3607eba87af2f4317c5987d769 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Sat, 4 Nov 2023 13:05:22 +1300 Subject: [PATCH 4/6] 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: + *

      + *
    • 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
    • + *
    + */ + 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); From 043dc5c51fb3d02f3feb07c4cfc559a282e2b94c Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Sun, 5 Nov 2023 22:01:02 +1300 Subject: [PATCH 5/6] Add setters without the set prefix to DatabaseBuilder with deprecation So add `name(String name)` as preferred to `setName(String name)` etc --- .../main/java/io/ebean/DatabaseBuilder.java | 1028 ++++++++++++++++- 1 file changed, 1025 insertions(+), 3 deletions(-) diff --git a/ebean-api/src/main/java/io/ebean/DatabaseBuilder.java b/ebean-api/src/main/java/io/ebean/DatabaseBuilder.java index 1975ddd0e..f3350d858 100644 --- a/ebean-api/src/main/java/io/ebean/DatabaseBuilder.java +++ b/ebean-api/src/main/java/io/ebean/DatabaseBuilder.java @@ -35,7 +35,7 @@ import java.util.function.Function; * .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)}. * @@ -67,6 +67,14 @@ public interface DatabaseBuilder { /** * Set the name of the Database. */ + default DatabaseBuilder name(String name) { + return setName(name); + } + + /** + * @deprecated migrate to {@link #name(String)}. + */ + @Deprecated DatabaseBuilder setName(String name); /** @@ -75,6 +83,14 @@ public interface DatabaseBuilder { *

* By default, this is set to true. */ + default DatabaseBuilder register(boolean register) { + return setRegister(register); + } + + /** + * @deprecated migrate to {@link #register(boolean)}. + */ + @Deprecated DatabaseBuilder setRegister(boolean register); /** @@ -83,6 +99,14 @@ public interface DatabaseBuilder { *

* This is only used when {@link #setRegister(boolean)} is also true. */ + default DatabaseBuilder defaultDatabase(boolean defaultServer) { + return setDefaultServer(defaultServer); + } + + /** + * @deprecated migrate to {@link #defaultDatabase(boolean)}. + */ + @Deprecated DatabaseBuilder setDefaultServer(boolean defaultServer); /** @@ -93,16 +117,40 @@ public interface DatabaseBuilder { *

  • Testing Docker - Set default schema on connection URL
  • * */ + default DatabaseBuilder dbSchema(String dbSchema) { + return setDbSchema(dbSchema); + } + + /** + * @deprecated migrate to {@link #setDbSchema(String)} + */ + @Deprecated DatabaseBuilder setDbSchema(String dbSchema); /** * Set the Geometry SRID. */ + default DatabaseBuilder geometrySRID(int geometrySRID) { + return setGeometrySRID(geometrySRID); + } + + /** + * @deprecated migrate to {@link #geometrySRID(int)}. + */ + @Deprecated DatabaseBuilder setGeometrySRID(int geometrySRID); /** * Set the time zone to use when reading/writing Timestamps via JDBC. */ + default DatabaseBuilder dataTimeZone(String dataTimeZone) { + return setDataTimeZone(dataTimeZone); + } + + /** + * @deprecated migrate to {@link #dataTimeZone(String)}. + */ + @Deprecated DatabaseBuilder setDataTimeZone(String dataTimeZone); /** @@ -112,6 +160,14 @@ public interface DatabaseBuilder { * 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. */ + default DatabaseBuilder persistBatch(PersistBatch persistBatch) { + return setPersistBatch(persistBatch); + } + + /** + * @deprecated migrate to {@link #persistBatch(PersistBatch)}. + */ + @Deprecated DatabaseBuilder setPersistBatch(PersistBatch persistBatch); /** @@ -122,6 +178,14 @@ public interface DatabaseBuilder { *

    * This only takes effect when the persistBatch mode at the transaction level does not take effect. */ + default DatabaseBuilder persistBatchOnCascade(PersistBatch persistBatchOnCascade) { + return setPersistBatchOnCascade(persistBatchOnCascade); + } + + /** + * @deprecated migrate to {@link #persistBatchOnCascade(PersistBatch)}. + */ + @Deprecated DatabaseBuilder setPersistBatchOnCascade(PersistBatch persistBatchOnCascade); /** @@ -135,6 +199,14 @@ public interface DatabaseBuilder { * When true this is equivalent to {@code setPersistBatch(PersistBatch.ALL)} or * when false to {@code setPersistBatch(PersistBatch.NONE)} */ + default DatabaseBuilder persistBatching(boolean persistBatching) { + return setPersistBatching(persistBatching); + } + + /** + * @deprecated migrate to {@link #persistBatching(boolean)}. + */ + @Deprecated DatabaseBuilder setPersistBatching(boolean persistBatching); /** @@ -144,14 +216,29 @@ public interface DatabaseBuilder { * * @see Transaction#setBatchSize(int) */ - DatabaseBuilder setPersistBatchSize(int persistBatchSize); + default DatabaseBuilder persistBatchSize(int persistBatchSize) { + return setPersistBatchSize(persistBatchSize); + } + /** + * @deprecated migrate to {@link #persistBatchSize(int)}. + */ + @Deprecated + 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)}. */ + default DatabaseBuilder disableLazyLoading(boolean disableLazyLoading) { + return setDisableLazyLoading(disableLazyLoading); + } + + /** + * @deprecated migrate to {@link #disableLazyLoading(boolean)}. + */ + @Deprecated DatabaseBuilder setDisableLazyLoading(boolean disableLazyLoading); /** @@ -165,21 +252,52 @@ public interface DatabaseBuilder { * You can explicitly control the lazy loading batch size for a given join on * a query using +lazy(batchSize) or JoinConfig. */ + default DatabaseBuilder lazyLoadBatchSize(int lazyLoadBatchSize) { + return setLazyLoadBatchSize(lazyLoadBatchSize); + } + + /** + * @deprecated migrate to {@link #lazyLoadBatchSize(int)}. + */ DatabaseBuilder setLazyLoadBatchSize(int lazyLoadBatchSize); /** * Set the clock used for setting the timestamps (e.g. @UpdatedTimestamp) on objects. */ + default DatabaseBuilder clock(Clock clock) { + return setClock(clock); + } + + /** + * @deprecated migrate to {@link #clock(Clock)}. + */ + @Deprecated DatabaseBuilder setClock(Clock clock); /** * Set the slow query time in millis. */ + default DatabaseBuilder slowQueryMillis(long slowQueryMillis) { + return setSlowQueryMillis(slowQueryMillis); + } + + /** + * @deprecated migrate to {@link #slowQueryMillis(long)}. + */ + @Deprecated DatabaseBuilder setSlowQueryMillis(long slowQueryMillis); /** * Set the slow query event listener. */ + default DatabaseBuilder slowQueryListener(SlowQueryListener slowQueryListener) { + return setSlowQueryListener(slowQueryListener); + } + + /** + * @deprecated migrate to {@link #slowQueryListener(SlowQueryListener)}. + */ + @Deprecated DatabaseBuilder setSlowQueryListener(SlowQueryListener slowQueryListener); /** @@ -222,16 +340,38 @@ public interface DatabaseBuilder { *

    * If not set a default implementation will be used. */ + default DatabaseBuilder jsonFactory(JsonFactory jsonFactory) { + return setJsonFactory(jsonFactory); + } + + /** + * @deprecated migrate to {@link #jsonFactory(JsonFactory)}. + */ DatabaseBuilder setJsonFactory(JsonFactory jsonFactory); /** * Set the JSON format to use for DateTime types. */ + default DatabaseBuilder jsonDateTime(JsonConfig.DateTime jsonDateTime) { + return setJsonDateTime(jsonDateTime); + } + + /** + * @deprecated migrate to {@link #jsonDateTime(JsonConfig.DateTime)}. + */ DatabaseBuilder setJsonDateTime(JsonConfig.DateTime jsonDateTime); /** * Set the JSON format to use for Date types. */ + default DatabaseBuilder jsonDate(JsonConfig.Date jsonDate) { + return setJsonDate(jsonDate); + } + + /** + * @deprecated migrate to {@link #jsonDateTime(JsonConfig.DateTime)}. + */ + @Deprecated DatabaseBuilder setJsonDate(JsonConfig.Date jsonDate); /** @@ -239,6 +379,14 @@ public interface DatabaseBuilder { *

    * Set to NON_NULL or NON_EMPTY to suppress nulls or null and empty collections respectively. */ + default DatabaseBuilder jsonInclude(JsonConfig.Include jsonInclude) { + return setJsonInclude(jsonInclude); + } + + /** + * @deprecated migrate to {@link #jsonInclude(JsonConfig.Include)}. + */ + @Deprecated DatabaseBuilder setJsonInclude(JsonConfig.Include jsonInclude); /** @@ -246,6 +394,14 @@ public interface DatabaseBuilder { * * @see DbJson#mutationDetection() */ + default DatabaseBuilder jsonMutationDetection(MutationDetection jsonMutationDetection) { + return setJsonMutationDetection(jsonMutationDetection); + } + + /** + * @deprecated migrate to {@link #jsonMutationDetection(MutationDetection)}. + */ + @Deprecated DatabaseBuilder setJsonMutationDetection(MutationDetection jsonMutationDetection); /** @@ -254,47 +410,119 @@ public interface DatabaseBuilder { * The container holds all the Database instances and provides clustering communication * services to all the Database instances. */ + default DatabaseBuilder containerConfig(ContainerConfig containerConfig) { + return setContainerConfig(containerConfig); + } + + /** + * @deprecated migrate to {@link #containerConfig(ContainerConfig)}. + */ + @Deprecated DatabaseBuilder setContainerConfig(ContainerConfig containerConfig); /** * Set the CurrentUserProvider. This is used to populate @WhoCreated, @WhoModified and * support other audit features (who executed a query etc). */ + default DatabaseBuilder currentUserProvider(CurrentUserProvider currentUserProvider) { + return setCurrentUserProvider(currentUserProvider); + } + + /** + * @deprecated migrate to {@link #currentUserProvider(CurrentUserProvider)}. + */ + @Deprecated DatabaseBuilder setCurrentUserProvider(CurrentUserProvider currentUserProvider); /** * Set the tenancy mode to use. */ + default DatabaseBuilder tenantMode(TenantMode tenantMode) { + return setTenantMode(tenantMode); + } + + /** + * @deprecated migrate to {@link #tenantMode(TenantMode)}. + */ + @Deprecated DatabaseBuilder setTenantMode(TenantMode tenantMode); /** * Set the column name used for TenantMode.PARTITION. */ + default DatabaseBuilder tenantPartitionColumn(String tenantPartitionColumn) { + return setTenantPartitionColumn(tenantPartitionColumn); + } + + /** + * @deprecated migrate to {@link #tenantPartitionColumn(String)}. + */ + @Deprecated DatabaseBuilder setTenantPartitionColumn(String tenantPartitionColumn); /** * Set the current tenant provider. */ + default DatabaseBuilder currentTenantProvider(CurrentTenantProvider currentTenantProvider) { + return setCurrentTenantProvider(currentTenantProvider); + } + + /** + * @deprecated migrate to {@link #currentTenantProvider(CurrentTenantProvider)}. + */ + @Deprecated DatabaseBuilder setCurrentTenantProvider(CurrentTenantProvider currentTenantProvider); /** * Set the tenancy datasource provider. */ + default DatabaseBuilder tenantDataSourceProvider(TenantDataSourceProvider tenantDataSourceProvider) { + return setTenantDataSourceProvider(tenantDataSourceProvider); + } + + /** + * @deprecated migrate to {@link #tenantDataSourceProvider(TenantDataSourceProvider)}. + */ + @Deprecated DatabaseBuilder setTenantDataSourceProvider(TenantDataSourceProvider tenantDataSourceProvider); /** * Set the tenancy schema provider. */ + default DatabaseBuilder tenantSchemaProvider(TenantSchemaProvider tenantSchemaProvider) { + return setTenantSchemaProvider(tenantSchemaProvider); + } + + /** + * @deprecated migrate to {@link #tenantSchemaProvider(TenantSchemaProvider)}. + */ + @Deprecated DatabaseBuilder setTenantSchemaProvider(TenantSchemaProvider tenantSchemaProvider); /** * Set the tenancy catalog provider. */ + default DatabaseBuilder tenantCatalogProvider(TenantCatalogProvider tenantCatalogProvider) { + return setTenantCatalogProvider(tenantCatalogProvider); + } + + /** + * @deprecated migrate to {@link #tenantCatalogProvider(TenantCatalogProvider)}. + */ + @Deprecated DatabaseBuilder setTenantCatalogProvider(TenantCatalogProvider tenantCatalogProvider); /** * Set to true if dirty beans are automatically persisted. */ + default DatabaseBuilder autoPersistUpdates(boolean autoPersistUpdates) { + return setAutoPersistUpdates(autoPersistUpdates); + } + + /** + * @deprecated migrate to {@link #autoPersistUpdates(boolean)}. + */ + @Deprecated DatabaseBuilder setAutoPersistUpdates(boolean autoPersistUpdates); /** @@ -302,8 +530,27 @@ public interface DatabaseBuilder { * * @param queryBatchSize the new query batch size */ + default DatabaseBuilder queryBatchSize(int queryBatchSize) { + return setQueryBatchSize(queryBatchSize); + } + + /** + * @deprecated migrate to {@link #queryBatchSize(int)}. + */ + @Deprecated DatabaseBuilder setQueryBatchSize(int queryBatchSize); + /** + * Set the default mapping for enum type. + */ + default DatabaseBuilder defaultEnumType(EnumType defaultEnumType) { + return setDefaultEnumType(defaultEnumType); + } + + /** + * @deprecated migrate to {@link #defaultEnumType(EnumType)}. + */ + @Deprecated DatabaseBuilder setDefaultEnumType(EnumType defaultEnumType); /** @@ -313,16 +560,40 @@ public interface DatabaseBuilder { * requests a sequence to be used as an Id for a bean (aka reduce network * chatter). */ + default DatabaseBuilder databaseSequenceBatchSize(int databaseSequenceBatchSize) { + return setDatabaseSequenceBatchSize(databaseSequenceBatchSize); + } + + /** + * @deprecated migrate to {@link #databaseSequenceBatchSize(int)}. + */ + @Deprecated DatabaseBuilder setDatabaseSequenceBatchSize(int databaseSequenceBatchSize); /** * Set the default JDBC fetchSize hint for findList queries. */ + default DatabaseBuilder jdbcFetchSizeFindList(int jdbcFetchSizeFindList) { + return setJdbcFetchSizeFindList(jdbcFetchSizeFindList); + } + + /** + * @deprecated migrate to {@link #jdbcFetchSizeFindList(int)}. + */ + @Deprecated DatabaseBuilder setJdbcFetchSizeFindList(int jdbcFetchSizeFindList); /** * Set the default JDBC fetchSize hint for findEach/findEachWhile queries. */ + default DatabaseBuilder jdbcFetchSizeFindEach(int jdbcFetchSizeFindEach) { + return setJdbcFetchSizeFindEach(jdbcFetchSizeFindEach); + } + + /** + * @deprecated migrate to {@link #jdbcFetchSizeFindEach(int)}. + */ + @Deprecated DatabaseBuilder setJdbcFetchSizeFindEach(int jdbcFetchSizeFindEach); /** @@ -331,12 +602,28 @@ 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. */ + default DatabaseBuilder changeLogPrepare(ChangeLogPrepare changeLogPrepare) { + return setChangeLogPrepare(changeLogPrepare); + } + + /** + * @deprecated migrate to {@link #changeLogPrepare(ChangeLogPrepare)}. + */ + @Deprecated DatabaseBuilder setChangeLogPrepare(ChangeLogPrepare changeLogPrepare); /** * Set the ChangeLogListener which actually performs the logging of change sets * in the background. */ + default DatabaseBuilder changeLogListener(ChangeLogListener changeLogListener) { + return setChangeLogListener(changeLogListener); + } + + /** + * @deprecated migrate to {@link #changeLogListener(ChangeLogListener)}. + */ + @Deprecated DatabaseBuilder setChangeLogListener(ChangeLogListener changeLogListener); /** @@ -344,16 +631,40 @@ public interface DatabaseBuilder { * bean type and in this way provide fine grained control over which persist requests * are included in the change log. */ + default DatabaseBuilder changeLogRegister(ChangeLogRegister changeLogRegister) { + return setChangeLogRegister(changeLogRegister); + } + + /** + * @deprecated migrate to {@link #changeLogRegister(ChangeLogRegister)}. + */ + @Deprecated DatabaseBuilder setChangeLogRegister(ChangeLogRegister changeLogRegister); /** * Set if inserts should be included in the change log by default. */ + default DatabaseBuilder changeLogIncludeInserts(boolean changeLogIncludeInserts) { + return setChangeLogIncludeInserts(changeLogIncludeInserts); + } + + /** + * @deprecated migrate to {@link #changeLogIncludeInserts(boolean)}. + */ + @Deprecated DatabaseBuilder setChangeLogIncludeInserts(boolean changeLogIncludeInserts); /** * Sets if the changelog should be written async (default = true). */ + default DatabaseBuilder changeLogAsync(boolean changeLogAsync) { + return setChangeLogAsync(changeLogAsync); + } + + /** + * @deprecated migrate to {@link #changeLogAsync(boolean)}. + */ + @Deprecated DatabaseBuilder setChangeLogAsync(boolean changeLogAsync); /** @@ -361,6 +672,14 @@ public interface DatabaseBuilder { * 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). */ + default DatabaseBuilder readAuditLogger(ReadAuditLogger readAuditLogger) { + return setReadAuditLogger(readAuditLogger); + } + + /** + * @deprecated migrate to {@link #readAuditLogger(ReadAuditLogger)}. + */ + @Deprecated DatabaseBuilder setReadAuditLogger(ReadAuditLogger readAuditLogger); /** @@ -370,105 +689,265 @@ public interface DatabaseBuilder { * (user id, user ip address etc) and sets it on the ReadEvent bean before it is sent * to the ReadAuditLogger. */ + default DatabaseBuilder readAuditPrepare(ReadAuditPrepare readAuditPrepare) { + return setReadAuditPrepare(readAuditPrepare); + } + + /** + * @deprecated migrate to {@link #readAuditPrepare(ReadAuditPrepare)}. + */ + @Deprecated DatabaseBuilder setReadAuditPrepare(ReadAuditPrepare readAuditPrepare); /** * Set the configuration for profiling. */ + default DatabaseBuilder profilingConfig(ProfilingConfig profilingConfig) { + return setProfilingConfig(profilingConfig); + } + + /** + * @deprecated migrate to {@link #profilingConfig(ProfilingConfig)}. + */ + @Deprecated 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. */ + default DatabaseBuilder asOfViewSuffix(String asOfViewSuffix) { + return setAsOfViewSuffix(asOfViewSuffix); + } + + /** + * @deprecated migrate to {@link #asOfViewSuffix(String)}. + */ + @Deprecated DatabaseBuilder setAsOfViewSuffix(String asOfViewSuffix); /** * Set the database column used to support history and 'As of' queries. This column is a timestamp range * or equivalent. */ + default DatabaseBuilder asOfSysPeriod(String asOfSysPeriod) { + return setAsOfSysPeriod(asOfSysPeriod); + } + + /** + * @deprecated migrate to {@link #asOfSysPeriod(String)}. + */ + @Deprecated DatabaseBuilder setAsOfSysPeriod(String asOfSysPeriod); /** * Set the history table suffix. */ + default DatabaseBuilder historyTableSuffix(String historyTableSuffix) { + return setHistoryTableSuffix(historyTableSuffix); + } + + /** + * @deprecated migrate to {@link #historyTableSuffix(String)}. + */ + @Deprecated DatabaseBuilder setHistoryTableSuffix(String historyTableSuffix); /** * Set to true if we are running in a JTA Transaction manager. */ + default DatabaseBuilder useJtaTransactionManager(boolean useJtaTransactionManager) { + return setUseJtaTransactionManager(useJtaTransactionManager); + } + + /** + * @deprecated migrate to {@link #useJtaTransactionManager(boolean)}. + */ + @Deprecated DatabaseBuilder setUseJtaTransactionManager(boolean useJtaTransactionManager); /** * Set the external transaction manager. */ + default DatabaseBuilder externalTransactionManager(ExternalTransactionManager externalTransactionManager) { + return setExternalTransactionManager(externalTransactionManager); + } + + /** + * @deprecated migrate to {@link #externalTransactionManager(ExternalTransactionManager)}. + */ + @Deprecated DatabaseBuilder setExternalTransactionManager(ExternalTransactionManager externalTransactionManager); /** * Set the ServerCachePlugin to use. */ + default DatabaseBuilder serverCachePlugin(ServerCachePlugin serverCachePlugin) { + return setServerCachePlugin(serverCachePlugin); + } + + /** + * @deprecated migrate to {@link #serverCachePlugin(ServerCachePlugin)}. + */ + @Deprecated 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. */ + default DatabaseBuilder eagerFetchLobs(boolean eagerFetchLobs) { + return setEagerFetchLobs(eagerFetchLobs); + } + + /** + * @deprecated migrate to {@link #eagerFetchLobs(boolean)}. + */ + @Deprecated DatabaseBuilder setEagerFetchLobs(boolean eagerFetchLobs); /** * Set the max call stack to use for origin location. */ + default DatabaseBuilder maxCallStack(int maxCallStack) { + return setMaxCallStack(maxCallStack); + } + + /** + * @deprecated migrate to {@link #maxCallStack(int)}. + */ + @Deprecated DatabaseBuilder setMaxCallStack(int maxCallStack); /** * Set to true if transactions should by default rollback on checked exceptions. */ + default DatabaseBuilder transactionRollbackOnChecked(boolean transactionRollbackOnChecked) { + return setTransactionRollbackOnChecked(transactionRollbackOnChecked); + } + + /** + * @deprecated migrate to {@link #transactionRollbackOnChecked(boolean)}. + */ + @Deprecated DatabaseBuilder setTransactionRollbackOnChecked(boolean transactionRollbackOnChecked); /** * Set the Background executor schedule pool size. */ + default DatabaseBuilder backgroundExecutorSchedulePoolSize(int backgroundExecutorSchedulePoolSize) { + return setBackgroundExecutorSchedulePoolSize(backgroundExecutorSchedulePoolSize); + } + + /** + * @deprecated migrate to {@link #backgroundExecutorSchedulePoolSize(int)}. + */ + @Deprecated 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. */ + default DatabaseBuilder backgroundExecutorShutdownSecs(int backgroundExecutorShutdownSecs) { + return setBackgroundExecutorShutdownSecs(backgroundExecutorShutdownSecs); + } + + /** + * @deprecated migrate to {@link #backgroundExecutorShutdownSecs(int)}. + */ + @Deprecated 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. */ + default DatabaseBuilder backgroundExecutorWrapper(BackgroundExecutorWrapper backgroundExecutorWrapper) { + return setBackgroundExecutorWrapper(backgroundExecutorWrapper); + } + + /** + * @deprecated migrate to {@link #backgroundExecutorWrapper(BackgroundExecutorWrapper)}. + */ + @Deprecated DatabaseBuilder setBackgroundExecutorWrapper(BackgroundExecutorWrapper backgroundExecutorWrapper); /** * Set the L2 cache default max size. */ + default DatabaseBuilder cacheMaxSize(int cacheMaxSize) { + return setCacheMaxSize(cacheMaxSize); + } + + /** + * @deprecated migrate to {@link #cacheMaxSize(int)}. + */ + @Deprecated DatabaseBuilder setCacheMaxSize(int cacheMaxSize); /** * Set the L2 cache default max idle time in seconds. */ + default DatabaseBuilder cacheMaxIdleTime(int cacheMaxIdleTime) { + return setCacheMaxIdleTime(cacheMaxIdleTime); + } + + /** + * @deprecated migrate to {@link #cacheMaxIdleTime(int)}. + */ + @Deprecated DatabaseBuilder setCacheMaxIdleTime(int cacheMaxIdleTime); /** * Set the L2 cache default max time to live in seconds. */ + default DatabaseBuilder cacheMaxTimeToLive(int cacheMaxTimeToLive) { + return setCacheMaxTimeToLive(cacheMaxTimeToLive); + } + + /** + * @deprecated migrate to {@link #cacheMaxTimeToLive(int)}. + */ + @Deprecated DatabaseBuilder setCacheMaxTimeToLive(int cacheMaxTimeToLive); /** * Set the L2 query cache default max size. */ + default DatabaseBuilder queryCacheMaxSize(int queryCacheMaxSize) { + return setQueryCacheMaxSize(queryCacheMaxSize); + } + + /** + * @deprecated migrate to {@link #queryCacheMaxSize(int)}. + */ + @Deprecated DatabaseBuilder setQueryCacheMaxSize(int queryCacheMaxSize); /** * Set the L2 query cache default max idle time in seconds. */ + default DatabaseBuilder queryCacheMaxIdleTime(int queryCacheMaxIdleTime) { + return setQueryCacheMaxIdleTime(queryCacheMaxIdleTime); + } + + /** + * @deprecated migrate to {@link #queryCacheMaxIdleTime(int)}. + */ + @Deprecated DatabaseBuilder setQueryCacheMaxIdleTime(int queryCacheMaxIdleTime); /** * Set the L2 query cache default max time to live in seconds. */ + default DatabaseBuilder queryCacheMaxTimeToLive(int queryCacheMaxTimeToLive) { + return setQueryCacheMaxTimeToLive(queryCacheMaxTimeToLive); + } + + /** + * @deprecated migrate to {@link #queryCacheMaxTimeToLive(int)}. + */ + @Deprecated DatabaseBuilder setQueryCacheMaxTimeToLive(int queryCacheMaxTimeToLive); /** @@ -476,6 +955,14 @@ public interface DatabaseBuilder { *

    * If none is set the default UnderscoreNamingConvention is used. */ + default DatabaseBuilder namingConvention(NamingConvention namingConvention) { + return setNamingConvention(namingConvention); + } + + /** + * @deprecated migrate to {@link #namingConvention(NamingConvention)}. + */ + @Deprecated DatabaseBuilder setNamingConvention(NamingConvention namingConvention); /** @@ -484,6 +971,14 @@ public interface DatabaseBuilder { * For Postgres pgjdbc version 42.3.0 should be used with datasource property * quoteReturningIdentifiers set to false (refer #2303). */ + default DatabaseBuilder allQuotedIdentifiers(boolean allQuotedIdentifiers) { + return setAllQuotedIdentifiers(allQuotedIdentifiers); + } + + /** + * @deprecated migrate to {@link #allQuotedIdentifiers(boolean)}. + */ + @Deprecated DatabaseBuilder setAllQuotedIdentifiers(boolean allQuotedIdentifiers); /** @@ -499,21 +994,53 @@ public interface DatabaseBuilder { /** * Set the constraint naming convention used in DDL generation. */ + default DatabaseBuilder constraintNaming(DbConstraintNaming constraintNaming) { + return setConstraintNaming(constraintNaming); + } + + /** + * @deprecated migrate to {@link #constraintNaming(DbConstraintNaming)}. + */ + @Deprecated DatabaseBuilder setConstraintNaming(DbConstraintNaming constraintNaming); /** * Set the configuration for AutoTune. */ + default DatabaseBuilder autoTuneConfig(AutoTuneConfig autoTuneConfig) { + return setAutoTuneConfig(autoTuneConfig); + } + + /** + * @deprecated migrate to {@link #autoTuneConfig(AutoTuneConfig)}. + */ + @Deprecated DatabaseBuilder setAutoTuneConfig(AutoTuneConfig autoTuneConfig); /** * Set to true to skip the startup DataSource check. */ + default DatabaseBuilder skipDataSourceCheck(boolean skipDataSourceCheck) { + return setSkipDataSourceCheck(skipDataSourceCheck); + } + + /** + * @deprecated migrate to {@link #skipDataSourceCheck(boolean)}. + */ + @Deprecated DatabaseBuilder setSkipDataSourceCheck(boolean skipDataSourceCheck); /** * Set a DataSource. */ + default DatabaseBuilder dataSource(DataSource dataSource) { + return setDataSource(dataSource); + } + + /** + * @deprecated migrate to {@link #dataSource(DataSource)}. + */ + @Deprecated DatabaseBuilder setDataSource(DataSource dataSource); /** @@ -525,22 +1052,54 @@ 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. */ + default DatabaseBuilder readOnlyDataSource(DataSource readOnlyDataSource) { + return setReadOnlyDataSource(readOnlyDataSource); + } + + /** + * @deprecated migrate to {@link #readOnlyDataSource(DataSource)}. + */ + @Deprecated DatabaseBuilder setReadOnlyDataSource(DataSource readOnlyDataSource); /** * Set the configuration required to build a DataSource using Ebean's own * DataSource implementation. */ + default DatabaseBuilder dataSourceBuilder(DataSourceBuilder dataSourceConfig) { + return setDataSourceConfig(dataSourceConfig); + } + + /** + * @deprecated migrate to {@link #dataSourceBuilder(DataSourceBuilder)}. + */ + @Deprecated DatabaseBuilder setDataSourceConfig(DataSourceBuilder dataSourceConfig); /** * Set to true if Ebean should create a DataSource for use with implicit read only transactions. */ + default DatabaseBuilder autoReadOnlyDataSource(boolean autoReadOnlyDataSource) { + return setAutoReadOnlyDataSource(autoReadOnlyDataSource); + } + + /** + * @deprecated migrate to {@link #autoReadOnlyDataSource(boolean)}. + */ + @Deprecated DatabaseBuilder setAutoReadOnlyDataSource(boolean autoReadOnlyDataSource); /** * Set the configuration for the read only DataSource. */ + default DatabaseBuilder readOnlyDataSourceBuilder(DataSourceBuilder readOnlyDataSourceConfig) { + return setReadOnlyDataSourceConfig(readOnlyDataSourceConfig); + } + + /** + * @deprecated migrate to {@link #readOnlyDataSourceBuilder(DataSourceBuilder)}. + */ + @Deprecated DatabaseBuilder setReadOnlyDataSourceConfig(DataSourceBuilder readOnlyDataSourceConfig); /** @@ -550,6 +1109,14 @@ public interface DatabaseBuilder { *

    * The value set is either a Integer or a String (e.g. "1", or "T"). */ + default DatabaseBuilder databaseBooleanTrue(String databaseTrue) { + return setDatabaseBooleanTrue(databaseTrue); + } + + /** + * @deprecated migrate to {@link #databaseBooleanTrue(String)}. + */ + @Deprecated DatabaseBuilder setDatabaseBooleanTrue(String databaseTrue); /** @@ -559,6 +1126,14 @@ public interface DatabaseBuilder { *

    * The value set is either a Integer or a String (e.g. "0", or "F"). */ + default DatabaseBuilder databaseBooleanFalse(String databaseFalse) { + return setDatabaseBooleanFalse(databaseFalse); + } + + /** + * @deprecated migrate to {@link #databaseBooleanFalse(String)}. + */ + @Deprecated DatabaseBuilder setDatabaseBooleanFalse(String databaseFalse); /** @@ -574,6 +1149,14 @@ 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. */ + default DatabaseBuilder databaseSequenceBatch(int databaseSequenceBatchSize) { + return setDatabaseSequenceBatch(databaseSequenceBatchSize); + } + + /** + * @deprecated migrate to {@link #databaseSequenceBatch(int)}. + */ + @Deprecated DatabaseBuilder setDatabaseSequenceBatch(int databaseSequenceBatchSize); /** @@ -589,6 +1172,14 @@ public interface DatabaseBuilder { *

    * Values are oracle, h2, postgres, mysql, sqlserver16, sqlserver17. */ + default DatabaseBuilder databasePlatformName(String databasePlatformName) { + return setDatabasePlatformName(databasePlatformName); + } + + /** + * @deprecated migrate to {@link #databasePlatformName(String)}. + */ + @Deprecated DatabaseBuilder setDatabasePlatformName(String databasePlatformName); /** @@ -597,11 +1188,27 @@ public interface DatabaseBuilder { * If none is set then the platform is determined via the databasePlatformName * or automatically via the JDBC driver information. */ + default DatabaseBuilder databasePlatform(DatabasePlatform databasePlatform) { + return setDatabasePlatform(databasePlatform); + } + + /** + * @deprecated migrate to {@link #databasePlatform(DatabasePlatform)}. + */ + @Deprecated DatabaseBuilder setDatabasePlatform(DatabasePlatform databasePlatform); /** * Set the preferred DB platform IdType. */ + default DatabaseBuilder idType(IdType idType) { + return setIdType(idType); + } + + /** + * @deprecated migrate to {@link #idType(IdType)}. + */ + @Deprecated DatabaseBuilder setIdType(IdType idType); /** @@ -616,6 +1223,14 @@ public interface DatabaseBuilder { * ebean.encryptKeyManager=org.avaje.tests.basic.encrypt.BasicEncyptKeyManager * } */ + default DatabaseBuilder encryptKeyManager(EncryptKeyManager encryptKeyManager) { + return setEncryptKeyManager(encryptKeyManager); + } + + /** + * @deprecated migrate to {@link #encryptKeyManager(EncryptKeyManager)}. + */ + @Deprecated DatabaseBuilder setEncryptKeyManager(EncryptKeyManager encryptKeyManager); /** @@ -624,6 +1239,14 @@ public interface DatabaseBuilder { * This is optionally used to programmatically define which columns are * encrypted instead of using the {@link Encrypted} Annotation. */ + default DatabaseBuilder encryptDeployManager(EncryptDeployManager encryptDeployManager) { + return setEncryptDeployManager(encryptDeployManager); + } + + /** + * @deprecated migrate to {@link #encryptDeployManager(EncryptDeployManager)}. + */ + @Deprecated DatabaseBuilder setEncryptDeployManager(EncryptDeployManager encryptDeployManager); /** @@ -633,6 +1256,14 @@ public interface DatabaseBuilder { * Ebean has a default implementation that it will use if you do not set your * own Encryptor implementation. */ + default DatabaseBuilder encryptor(Encryptor encryptor) { + return setEncryptor(encryptor); + } + + /** + * @deprecated migrate to {@link #encryptor(Encryptor)}. + */ + @Deprecated DatabaseBuilder setEncryptor(Encryptor encryptor); /** @@ -641,6 +1272,14 @@ public interface DatabaseBuilder { * Typically used to create an Database instance for DDL Migration generation * without requiring a real DataSource / Database to connect to. */ + default DatabaseBuilder offline(boolean dbOffline) { + return setDbOffline(dbOffline); + } + + /** + * @deprecated migrate to {@link #offline(boolean)}. + */ + @Deprecated DatabaseBuilder setDbOffline(boolean dbOffline); /** @@ -649,31 +1288,79 @@ 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) */ + default DatabaseBuilder dbEncrypt(DbEncrypt dbEncrypt) { + return setDbEncrypt(dbEncrypt); + } + + /** + * @deprecated migrate to {@link #dbEncrypt(DbEncrypt)}. + */ + @Deprecated DatabaseBuilder setDbEncrypt(DbEncrypt dbEncrypt); /** * Set the configuration for DB platform (such as UUID and custom mappings). */ + default DatabaseBuilder platformConfig(PlatformConfig platformConfig) { + return setPlatformConfig(platformConfig); + } + + /** + * @deprecated migrate to {@link #platformConfig(PlatformConfig)}. + */ + @Deprecated DatabaseBuilder setPlatformConfig(PlatformConfig platformConfig); /** * Set the DB type used to store UUID. */ + default DatabaseBuilder dbUuid(PlatformConfig.DbUuid dbUuid) { + return setDbUuid(dbUuid); + } + + /** + * @deprecated migrate to {@link #dbUuid(PlatformConfig.DbUuid)}. + */ + @Deprecated DatabaseBuilder setDbUuid(PlatformConfig.DbUuid dbUuid); /** * Sets the UUID version mode. */ + default DatabaseBuilder uuidVersion(DatabaseConfig.UuidVersion uuidVersion) { + return setUuidVersion(uuidVersion); + } + + /** + * @deprecated migrate to {@link #uuidVersion(DatabaseConfig.UuidVersion)}. + */ + @Deprecated DatabaseBuilder setUuidVersion(DatabaseConfig.UuidVersion uuidVersion); /** * Set the UUID state file. */ + default DatabaseBuilder uuidStateFile(String uuidStateFile) { + return setUuidStateFile(uuidStateFile); + } + + /** + * @deprecated migrate to {@link #uuidStateFile(String)}. + */ + @Deprecated DatabaseBuilder setUuidStateFile(String uuidStateFile); /** * Sets the V1-UUID-NodeId. */ + default DatabaseBuilder uuidNodeId(String uuidNodeId) { + return setUuidNodeId(uuidNodeId); + } + + /** + * @deprecated migrate to {@link #uuidNodeId(String)}. + */ + @Deprecated DatabaseBuilder setUuidNodeId(String uuidNodeId); /** @@ -681,6 +1368,14 @@ public interface DatabaseBuilder { *

    * Otherwise it is persisted using java.sql.Time which is seconds precision. */ + default DatabaseBuilder localTimeWithNanos(boolean localTimeWithNanos) { + return setLocalTimeWithNanos(localTimeWithNanos); + } + + /** + * @deprecated migrate to {@link #localTimeWithNanos(boolean)}. + */ + @Deprecated DatabaseBuilder setLocalTimeWithNanos(boolean localTimeWithNanos); /** @@ -688,6 +1383,14 @@ public interface DatabaseBuilder { *

    * Otherwise it is persisted with second precision (SQL INTEGER). */ + default DatabaseBuilder durationWithNanos(boolean durationWithNanos) { + return setDurationWithNanos(durationWithNanos); + } + + /** + * @deprecated migrate to {@link #durationWithNanos(boolean)}. + */ + @Deprecated DatabaseBuilder setDurationWithNanos(boolean durationWithNanos); /** @@ -696,6 +1399,14 @@ 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. */ + default DatabaseBuilder runMigration(boolean runMigration) { + return setRunMigration(runMigration); + } + + /** + * @deprecated migrate to {@link #runMigration(boolean)}. + */ + @Deprecated DatabaseBuilder setRunMigration(boolean runMigration); /** @@ -704,6 +1415,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. */ + default DatabaseBuilder ddlGenerate(boolean ddlGenerate) { + return setDdlGenerate(ddlGenerate); + } + + /** + * @deprecated migrate to {@link #ddlGenerate(boolean)}. + */ + @Deprecated DatabaseBuilder setDdlGenerate(boolean ddlGenerate); /** @@ -712,6 +1431,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. */ + default DatabaseBuilder ddlRun(boolean ddlRun) { + return setDdlRun(ddlRun); + } + + /** + * @deprecated migrate to {@link #ddlRun(boolean)}. + */ + @Deprecated DatabaseBuilder setDdlRun(boolean ddlRun); /** @@ -719,6 +1446,14 @@ public interface DatabaseBuilder { *

    * Typically we want this on when we are running tests. */ + default DatabaseBuilder ddlExtra(boolean ddlExtra) { + return setDdlExtra(ddlExtra); + } + + /** + * @deprecated migrate to {@link #ddlExtra(boolean)}. + */ + @Deprecated DatabaseBuilder setDdlExtra(boolean ddlExtra); /** @@ -727,6 +1462,14 @@ 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. */ + default DatabaseBuilder ddlCreateOnly(boolean ddlCreateOnly) { + return setDdlCreateOnly(ddlCreateOnly); + } + + /** + * @deprecated migrate to {@link #ddlCreateOnly(boolean)}. + */ + @Deprecated DatabaseBuilder setDdlCreateOnly(boolean ddlCreateOnly); /** @@ -735,31 +1478,79 @@ 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. */ + default DatabaseBuilder ddlSeedSql(String ddlSeedSql) { + return setDdlSeedSql(ddlSeedSql); + } + + /** + * @deprecated migrate to {@link #ddlSeedSql(String)}. + */ + @Deprecated DatabaseBuilder setDdlSeedSql(String ddlSeedSql); /** * Set a SQL script to execute before the "create all" DDL has been run. */ + default DatabaseBuilder ddlInitSql(String ddlInitSql) { + return setDdlInitSql(ddlInitSql); + } + + /** + * @deprecated migrate to {@link #ddlInitSql(String)}. + */ + @Deprecated DatabaseBuilder setDdlInitSql(String ddlInitSql); /** * Set the header to use with DDL generation. */ + default DatabaseBuilder ddlHeader(String ddlHeader) { + return setDdlHeader(ddlHeader); + } + + /** + * @deprecated migrate to {@link #ddlHeader(String)}. + */ + @Deprecated DatabaseBuilder setDdlHeader(String ddlHeader); /** * Set to false to turn off strict mode allowing non-null columns to not have a default value. */ + default DatabaseBuilder ddlStrictMode(boolean ddlStrictMode) { + return setDdlStrictMode(ddlStrictMode); + } + + /** + * @deprecated migrate to {@link #ddlStrictMode(boolean)}. + */ + @Deprecated DatabaseBuilder setDdlStrictMode(boolean ddlStrictMode); /** * Set a comma and equals delimited placeholders that are substituted in DDL scripts. */ + default DatabaseBuilder ddlPlaceholders(String ddlPlaceholders) { + return setDdlPlaceholders(ddlPlaceholders); + } + + /** + * @deprecated migrate to {@link #ddlPlaceholders(String)}. + */ + @Deprecated DatabaseBuilder setDdlPlaceholders(String ddlPlaceholders); /** * Set a map of placeholder values that are substituted in DDL scripts. */ + default DatabaseBuilder ddlPlaceholderMap(Map ddlPlaceholderMap) { + return setDdlPlaceholderMap(ddlPlaceholderMap); + } + + /** + * @deprecated migrate to {@link #ddlPlaceholderMap(Map)}. + */ + @Deprecated DatabaseBuilder setDdlPlaceholderMap(Map ddlPlaceholderMap); /** @@ -767,11 +1558,27 @@ public interface DatabaseBuilder { * have been registered. This can be used to start an Database instance just to use the * SQL functions such as SqlQuery, SqlUpdate etc. */ + default DatabaseBuilder disableClasspathSearch(boolean disableClasspathSearch) { + return setDisableClasspathSearch(disableClasspathSearch); + } + + /** + * @deprecated migrate to {@link #disableClasspathSearch(boolean)}. + */ + @Deprecated DatabaseBuilder setDisableClasspathSearch(boolean disableClasspathSearch); /** * Set the mode to use for Joda LocalTime support 'normal' or 'utc'. */ + default DatabaseBuilder jodaLocalTimeMode(String jodaLocalTimeMode) { + return setJodaLocalTimeMode(jodaLocalTimeMode); + } + + /** + * @deprecated migrate to {@link #jodaLocalTimeMode(String)}. + */ + @Deprecated DatabaseBuilder setJodaLocalTimeMode(String jodaLocalTimeMode); /** @@ -820,6 +1627,14 @@ public interface DatabaseBuilder { /** * Set to false when we still want to hit the cache after a write has occurred on a transaction. */ + default DatabaseBuilder skipCacheAfterWrite(boolean skipCacheAfterWrite) { + return setSkipCacheAfterWrite(skipCacheAfterWrite); + } + + /** + * @deprecated migrate to {@link #skipCacheAfterWrite(boolean)}. + */ + @Deprecated DatabaseBuilder setSkipCacheAfterWrite(boolean skipCacheAfterWrite); /** @@ -829,11 +1644,27 @@ public interface DatabaseBuilder { * * @see Transaction#setUpdateAllLoadedProperties(boolean) */ + default DatabaseBuilder updateAllPropertiesInBatch(boolean updateAllPropertiesInBatch) { + return setUpdateAllPropertiesInBatch(updateAllPropertiesInBatch); + } + + /** + * @deprecated migrate to {@link #updateAllPropertiesInBatch(boolean)}. + */ + @Deprecated DatabaseBuilder setUpdateAllPropertiesInBatch(boolean updateAllPropertiesInBatch); /** * Sets the resource directory. */ + default DatabaseBuilder resourceDirectory(String resourceDirectory) { + return setResourceDirectory(resourceDirectory); + } + + /** + * @deprecated migrate to {@link #resourceDirectory(String)}. + */ + @Deprecated DatabaseBuilder setResourceDirectory(String resourceDirectory); /** @@ -983,12 +1814,28 @@ public interface DatabaseBuilder { * * @see Query#setPersistenceContextScope(PersistenceContextScope) */ + default DatabaseBuilder persistenceContextScope(PersistenceContextScope persistenceContextScope) { + return setPersistenceContextScope(persistenceContextScope); + } + + /** + * @deprecated migrate to {@link #persistenceContextScope(PersistenceContextScope)}. + */ + @Deprecated 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. */ + default DatabaseBuilder classLoadConfig(ClassLoadConfig classLoadConfig) { + return setClassLoadConfig(classLoadConfig); + } + + /** + * @deprecated migrate to {@link #classLoadConfig(ClassLoadConfig)}. + */ + @Deprecated DatabaseBuilder setClassLoadConfig(ClassLoadConfig classLoadConfig); /** @@ -1009,6 +1856,14 @@ public interface DatabaseBuilder { *

    * Note that this is not strongly typed as Jackson ObjectMapper is an optional dependency. */ + default DatabaseBuilder objectMapper(Object objectMapper) { + return setObjectMapper(objectMapper); + } + + /** + * @deprecated migrate to {@link #objectMapper(Object)}. + */ + @Deprecated DatabaseBuilder setObjectMapper(Object objectMapper); /** @@ -1018,26 +1873,66 @@ 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". */ + default DatabaseBuilder expressionEqualsWithNullAsNoop(boolean expressionEqualsWithNullAsNoop) { + return setExpressionEqualsWithNullAsNoop(expressionEqualsWithNullAsNoop); + } + + /** + * @deprecated migrate to {@link #expressionEqualsWithNullAsNoop(boolean)}. + */ + @Deprecated DatabaseBuilder setExpressionEqualsWithNullAsNoop(boolean expressionEqualsWithNullAsNoop); /** * Set to true to use native ILIKE expression if supported by the database platform (e.g. Postgres). */ + default DatabaseBuilder expressionNativeIlike(boolean expressionNativeIlike) { + return setExpressionNativeIlike(expressionNativeIlike); + } + + /** + * @deprecated migrate to {@link #expressionNativeIlike(boolean)}. + */ + @Deprecated DatabaseBuilder setExpressionNativeIlike(boolean expressionNativeIlike); /** * Set the enabled L2 cache regions (comma delimited). */ + default DatabaseBuilder enabledL2Regions(String enabledL2Regions) { + return setEnabledL2Regions(enabledL2Regions); + } + + /** + * @deprecated migrate to {@link #enabledL2Regions(String)}. + */ + @Deprecated DatabaseBuilder setEnabledL2Regions(String enabledL2Regions); /** * Set to true to disable L2 caching. Typically useful in performance testing. */ + default DatabaseBuilder disableL2Cache(boolean disableL2Cache) { + return setDisableL2Cache(disableL2Cache); + } + + /** + * @deprecated migrate to {@link #disableL2Cache(boolean)}. + */ + @Deprecated DatabaseBuilder setDisableL2Cache(boolean disableL2Cache); /** * Force the use of local only L2 cache. Effectively ignore l2 cache plugin like ebean-redis etc. */ + default DatabaseBuilder localOnlyL2Cache(boolean localOnlyL2Cache) { + return setLocalOnlyL2Cache(localOnlyL2Cache); + } + + /** + * @deprecated migrate to {@link #localOnlyL2Cache(boolean)}. + */ + @Deprecated DatabaseBuilder setLocalOnlyL2Cache(boolean localOnlyL2Cache); /** @@ -1049,6 +1944,14 @@ 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. */ + default DatabaseBuilder useValidationNotNull(boolean useValidationNotNull) { + return setUseValidationNotNull(useValidationNotNull); + } + + /** + * @deprecated migrate to {@link #useValidationNotNull(boolean)}. + */ + @Deprecated DatabaseBuilder setUseValidationNotNull(boolean useValidationNotNull); /** @@ -1058,6 +1961,14 @@ 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. */ + default DatabaseBuilder notifyL2CacheInForeground(boolean notifyL2CacheInForeground) { + return setNotifyL2CacheInForeground(notifyL2CacheInForeground); + } + + /** + * @deprecated migrate to {@link #notifyL2CacheInForeground(boolean)}. + */ + @Deprecated DatabaseBuilder setNotifyL2CacheInForeground(boolean notifyL2CacheInForeground); /** @@ -1066,6 +1977,14 @@ 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. */ + default DatabaseBuilder queryPlanTTLSeconds(int queryPlanTTLSeconds) { + return setQueryPlanTTLSeconds(queryPlanTTLSeconds); + } + + /** + * @deprecated migrate to {@link #queryPlanTTLSeconds(int)}. + */ + @Deprecated DatabaseBuilder setQueryPlanTTLSeconds(int queryPlanTTLSeconds); /** @@ -1091,17 +2010,41 @@ public interface DatabaseBuilder { *

    * This is only used if classes have not been explicitly specified. */ + default DatabaseBuilder mappingLocations(List mappingLocations) { + return setMappingLocations(mappingLocations); + } + + /** + * @deprecated migrate to {@link #mappingLocations(List)}. + */ + @Deprecated 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. */ + default DatabaseBuilder idGeneratorAutomatic(boolean idGeneratorAutomatic) { + return setIdGeneratorAutomatic(idGeneratorAutomatic); + } + + /** + * @deprecated migrate to {@link #idGeneratorAutomatic(boolean)}. + */ + @Deprecated DatabaseBuilder setIdGeneratorAutomatic(boolean idGeneratorAutomatic); /** * Set to true to enable query plan capture. */ + default DatabaseBuilder queryPlanEnable(boolean queryPlanEnable) { + return setQueryPlanEnable(queryPlanEnable); + } + + /** + * @deprecated migrate to {@link #queryPlanEnable(boolean)}. + */ + @Deprecated DatabaseBuilder setQueryPlanEnable(boolean queryPlanEnable); /** @@ -1110,16 +2053,40 @@ public interface DatabaseBuilder { * Queries executing slower than this will have bind values captured such that later * the query plan can be captured and reported. */ + default DatabaseBuilder queryPlanThresholdMicros(long queryPlanThresholdMicros) { + return setQueryPlanThresholdMicros(queryPlanThresholdMicros); + } + + /** + * @deprecated migrate to {@link #queryPlanThresholdMicros(long)}. + */ + @Deprecated DatabaseBuilder setQueryPlanThresholdMicros(long queryPlanThresholdMicros); /** * Set to true to turn on periodic capture of query plans. */ + default DatabaseBuilder queryPlanCapture(boolean queryPlanCapture) { + return setQueryPlanCapture(queryPlanCapture); + } + + /** + * @deprecated migrate to {@link #queryPlanCapture(boolean)}. + */ + @Deprecated DatabaseBuilder setQueryPlanCapture(boolean queryPlanCapture); /** * Set the frequency in seconds to capture query plans. */ + default DatabaseBuilder queryPlanCapturePeriodSecs(long queryPlanCapturePeriodSecs) { + return setQueryPlanCapturePeriodSecs(queryPlanCapturePeriodSecs); + } + + /** + * @deprecated migrate to {@link #queryPlanCapturePeriodSecs(long)}. + */ + @Deprecated DatabaseBuilder setQueryPlanCapturePeriodSecs(long queryPlanCapturePeriodSecs); /** @@ -1129,21 +2096,53 @@ public interface DatabaseBuilder { * Effectively this controls the amount of load/time we want to * allow for query plan capture. */ + default DatabaseBuilder queryPlanCaptureMaxTimeMillis(long queryPlanCaptureMaxTimeMillis) { + return setQueryPlanCaptureMaxTimeMillis(queryPlanCaptureMaxTimeMillis); + } + + /** + * @deprecated migrate to {@link #queryPlanCaptureMaxTimeMillis(long)}. + */ + @Deprecated DatabaseBuilder setQueryPlanCaptureMaxTimeMillis(long queryPlanCaptureMaxTimeMillis); /** * Set the max number of query plans captured per request. */ + default DatabaseBuilder queryPlanCaptureMaxCount(int queryPlanCaptureMaxCount) { + return setQueryPlanCaptureMaxCount(queryPlanCaptureMaxCount); + } + + /** + * @deprecated migrate to {@link #queryPlanCaptureMaxCount(int)}. + */ + @Deprecated DatabaseBuilder setQueryPlanCaptureMaxCount(int queryPlanCaptureMaxCount); /** * Set the listener used to process captured query plans. */ + default DatabaseBuilder queryPlanListener(QueryPlanListener queryPlanListener) { + return setQueryPlanListener(queryPlanListener); + } + + /** + * @deprecated migrate to {@link #queryPlanListener(QueryPlanListener)}. + */ + @Deprecated DatabaseBuilder setQueryPlanListener(QueryPlanListener queryPlanListener); /** * Set to true if metrics should be dumped when the server is shutdown. */ + default DatabaseBuilder dumpMetricsOnShutdown(boolean dumpMetricsOnShutdown) { + return setDumpMetricsOnShutdown(dumpMetricsOnShutdown); + } + + /** + * @deprecated migrate to {@link #dumpMetricsOnShutdown(boolean)}. + */ + @Deprecated DatabaseBuilder setDumpMetricsOnShutdown(boolean dumpMetricsOnShutdown); /** @@ -1151,6 +2150,14 @@ public interface DatabaseBuilder { * * @param dumpMetricsOptions Example "sql,hash", "sql" */ + default DatabaseBuilder dumpMetricsOptions(String dumpMetricsOptions) { + return setDumpMetricsOptions(dumpMetricsOptions); + } + + /** + * @deprecated migrate to {@link #dumpMetricsOptions(String)}. + */ + @Deprecated DatabaseBuilder setDumpMetricsOptions(String dumpMetricsOptions); /** @@ -1160,13 +2167,28 @@ public interface DatabaseBuilder { * can register the entity bean classes (to aDatabaseBuilder classpath scanning). * This is on by default and setting this to false turns it off. */ + default DatabaseBuilder loadModuleInfo(boolean loadModuleInfo) { + return setLoadModuleInfo(loadModuleInfo); + } + + /** + * @deprecated migrate to {@link #loadModuleInfo(boolean)}. + */ + @Deprecated DatabaseBuilder setLoadModuleInfo(boolean loadModuleInfo); /** * Set the naming convention to apply to metrics names. */ - DatabaseBuilder setMetricNaming(Function metricNaming); + default DatabaseBuilder metricNaming(Function metricNaming) { + return setMetricNaming(metricNaming); + } + /** + * @deprecated migrate to {@link #metricNaming(Function)}. + */ + @Deprecated + DatabaseBuilder setMetricNaming(Function metricNaming); /** * Provides read access (getters) for the DatabaseBuilder configuration From 3edc2320030d22a23795e95a8fba21b70c0b718b Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Sun, 5 Nov 2023 22:03:25 +1300 Subject: [PATCH 6/6] Update test BeanDescriptor_registerTest with DatabaseBuilder use --- .../server/deploy/BeanDescriptor_registerTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 d72ccddad..373e836b5 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 @@ -17,11 +17,11 @@ public class BeanDescriptor_registerTest { public void testRegisterDeregister() { Database db = Database.builder() - .setName("h2other") + .name("h2other") .loadFromProperties() - .setDdlExtra(false) - .setRegister(false) - .setDefaultServer(false) + .ddlExtra(false) + .register(false) + .defaultDatabase(false) .addClass(EBasic.class) .build();