* 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. * @@ -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
new file mode 100644
index 000000000..f3350d858
--- /dev/null
+++ b/ebean-api/src/main/java/io/ebean/DatabaseBuilder.java
@@ -0,0 +1,3068 @@
+package io.ebean;
+
+import com.fasterxml.jackson.core.JsonFactory;
+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;
+
+/**
+ * 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.
+ */
+ default DatabaseBuilder name(String name) {
+ return setName(name);
+ }
+
+ /**
+ * @deprecated migrate to {@link #name(String)}.
+ */
+ @Deprecated
+ 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. + */ + default DatabaseBuilder register(boolean register) { + return setRegister(register); + } + + /** + * @deprecated migrate to {@link #register(boolean)}. + */ + @Deprecated + 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. + */ + default DatabaseBuilder defaultDatabase(boolean defaultServer) { + return setDefaultServer(defaultServer); + } + + /** + * @deprecated migrate to {@link #defaultDatabase(boolean)}. + */ + @Deprecated + DatabaseBuilder setDefaultServer(boolean defaultServer); + + /** + * Set the DB schema to use. This specifies to use this schema for: + *
+ * 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. + */ + default DatabaseBuilder persistBatch(PersistBatch persistBatch) { + return setPersistBatch(persistBatch); + } + + /** + * @deprecated migrate to {@link #persistBatch(PersistBatch)}. + */ + @Deprecated + 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. + */ + default DatabaseBuilder persistBatchOnCascade(PersistBatch persistBatchOnCascade) { + return setPersistBatchOnCascade(persistBatchOnCascade); + } + + /** + * @deprecated migrate to {@link #persistBatchOnCascade(PersistBatch)}. + */ + @Deprecated + 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)} + */ + default DatabaseBuilder persistBatching(boolean persistBatching) { + return setPersistBatching(persistBatching); + } + + /** + * @deprecated migrate to {@link #persistBatching(boolean)}. + */ + @Deprecated + 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) + */ + 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); + + /** + * 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. + */ + 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); + + /** + * 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. + */ + DatabaseBuilder 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. + *
{@code
+ *
+ * JedisPool jedisPool = ..
+ *
+ * config.putServiceObject(jedisPool);
+ *
+ * }
+ */
+ DatabaseBuilder putServiceObject(Object configObject);
+
+ /**
+ * Set the Jackson JsonFactory to use.
+ * + * 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); + + /** + * 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. + */ + default DatabaseBuilder jsonInclude(JsonConfig.Include jsonInclude) { + return setJsonInclude(jsonInclude); + } + + /** + * @deprecated migrate to {@link #jsonInclude(JsonConfig.Include)}. + */ + @Deprecated + DatabaseBuilder setJsonInclude(JsonConfig.Include jsonInclude); + + /** + * Set the default MutableDetection to use with {@code @DbJson} using Jackson. + * + * @see DbJson#mutationDetection() + */ + default DatabaseBuilder jsonMutationDetection(MutationDetection jsonMutationDetection) { + return setJsonMutationDetection(jsonMutationDetection); + } + + /** + * @deprecated migrate to {@link #jsonMutationDetection(MutationDetection)}. + */ + @Deprecated + DatabaseBuilder setJsonMutationDetection(MutationDetection jsonMutationDetection); + + /** + * Set the container / clustering configuration. + *
+ * 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); + + /** + * Sets the query batch size. This defaults to 100. + * + * @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); + + /** + * 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). + */ + 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); + + /** + * 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. + */ + 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); + + /** + * 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. + */ + 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); + + /** + * 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). + */ + default DatabaseBuilder readAuditLogger(ReadAuditLogger readAuditLogger) { + return setReadAuditLogger(readAuditLogger); + } + + /** + * @deprecated migrate to {@link #readAuditLogger(ReadAuditLogger)}. + */ + @Deprecated + DatabaseBuilder setReadAuditLogger(ReadAuditLogger readAuditLogger); + + /** + * 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. + */ + 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); + + /** + * Set the NamingConvention. + *
+ * 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); + + /** + * 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). + */ + default DatabaseBuilder allQuotedIdentifiers(boolean allQuotedIdentifiers) { + return setAllQuotedIdentifiers(allQuotedIdentifiers); + } + + /** + * @deprecated migrate to {@link #allQuotedIdentifiers(boolean)}. + */ + @Deprecated + DatabaseBuilder setAllQuotedIdentifiers(boolean allQuotedIdentifiers); + + /** + * Set to true if this Database is Document store only instance (has no JDBC DB). + */ + DatabaseBuilder setDocStoreOnly(boolean docStoreOnly); + + /** + * Set the configuration for the ElasticSearch integration. + */ + DatabaseBuilder setDocStoreConfig(DocStoreConfig docStoreConfig); + + /** + * 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); + + /** + * 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. + */ + 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); + + /** + * 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"). + */ + default DatabaseBuilder databaseBooleanTrue(String databaseTrue) { + return setDatabaseBooleanTrue(databaseTrue); + } + + /** + * @deprecated migrate to {@link #databaseBooleanTrue(String)}. + */ + @Deprecated + DatabaseBuilder setDatabaseBooleanTrue(String databaseTrue); + + /** + * 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"). + */ + default DatabaseBuilder databaseBooleanFalse(String databaseFalse) { + return setDatabaseBooleanFalse(databaseFalse); + } + + /** + * @deprecated migrate to {@link #databaseBooleanFalse(String)}. + */ + @Deprecated + DatabaseBuilder setDatabaseBooleanFalse(String databaseFalse); + + /** + * 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. + */ + default DatabaseBuilder databaseSequenceBatch(int databaseSequenceBatchSize) { + return setDatabaseSequenceBatch(databaseSequenceBatchSize); + } + + /** + * @deprecated migrate to {@link #databaseSequenceBatch(int)}. + */ + @Deprecated + DatabaseBuilder setDatabaseSequenceBatch(int databaseSequenceBatchSize); + + /** + * 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. + */ + default DatabaseBuilder databasePlatformName(String databasePlatformName) { + return setDatabasePlatformName(databasePlatformName); + } + + /** + * @deprecated migrate to {@link #databasePlatformName(String)}. + */ + @Deprecated + DatabaseBuilder setDatabasePlatformName(String databasePlatformName); + + /** + * 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. + */ + 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); + + /** + * 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
+ * }
+ */
+ default DatabaseBuilder encryptKeyManager(EncryptKeyManager encryptKeyManager) {
+ return setEncryptKeyManager(encryptKeyManager);
+ }
+
+ /**
+ * @deprecated migrate to {@link #encryptKeyManager(EncryptKeyManager)}.
+ */
+ @Deprecated
+ DatabaseBuilder setEncryptKeyManager(EncryptKeyManager encryptKeyManager);
+
+ /**
+ * Set the EncryptDeployManager.
+ * + * 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); + + /** + * 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. + */ + default DatabaseBuilder encryptor(Encryptor encryptor) { + return setEncryptor(encryptor); + } + + /** + * @deprecated migrate to {@link #encryptor(Encryptor)}. + */ + @Deprecated + DatabaseBuilder setEncryptor(Encryptor encryptor); + + /** + * 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. + */ + default DatabaseBuilder offline(boolean dbOffline) { + return setDbOffline(dbOffline); + } + + /** + * @deprecated migrate to {@link #offline(boolean)}. + */ + @Deprecated + DatabaseBuilder setDbOffline(boolean dbOffline); + + /** + * 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) + */ + 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); + + /** + * Set to true if LocalTime should be persisted with nanos precision. + *
+ * 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); + + /** + * Set to true if Duration should be persisted with nanos precision (SQL DECIMAL). + *
+ * 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); + + /** + * 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. + */ + default DatabaseBuilder runMigration(boolean runMigration) { + return setRunMigration(runMigration); + } + + /** + * @deprecated migrate to {@link #runMigration(boolean)}. + */ + @Deprecated + DatabaseBuilder setRunMigration(boolean 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. + */ + default DatabaseBuilder ddlGenerate(boolean ddlGenerate) { + return setDdlGenerate(ddlGenerate); + } + + /** + * @deprecated migrate to {@link #ddlGenerate(boolean)}. + */ + @Deprecated + DatabaseBuilder 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. + */ + default DatabaseBuilder ddlRun(boolean ddlRun) { + return setDdlRun(ddlRun); + } + + /** + * @deprecated migrate to {@link #ddlRun(boolean)}. + */ + @Deprecated + 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. + */ + default DatabaseBuilder ddlExtra(boolean ddlExtra) { + return setDdlExtra(ddlExtra); + } + + /** + * @deprecated migrate to {@link #ddlExtra(boolean)}. + */ + @Deprecated + DatabaseBuilder setDdlExtra(boolean ddlExtra); + + /** + * 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. + */ + default DatabaseBuilder ddlCreateOnly(boolean ddlCreateOnly) { + return setDdlCreateOnly(ddlCreateOnly); + } + + /** + * @deprecated migrate to {@link #ddlCreateOnly(boolean)}. + */ + @Deprecated + DatabaseBuilder setDdlCreateOnly(boolean ddlCreateOnly); + + /** + * 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.
+ */
+ 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
+ * 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.
+ */
+ DatabaseBuilder addClass(Class> cls);
+
+ /**
+ * Register all the classes (typically entity classes).
+ */
+ DatabaseBuilder addAll(Collection
+ * This is only used if classes have not been explicitly specified.
+ */
+ 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.
+ */
+ DatabaseBuilder setPackages(List
+ * 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)}.
+ */
+ DatabaseBuilder classes(Collection
+ * This mode can be explicitly set per transaction.
+ *
+ * @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);
+
+ /**
+ * Add a custom type mapping.
+ *
+ *
+ *
+ * Note alternatively you can use {@link #setQueryAdapters(List)} to set all
+ * the BeanQueryAdapter instances.
+ */
+ DatabaseBuilder add(BeanQueryAdapter beanQueryAdapter);
+
+ /**
+ * Register all the BeanQueryAdapter instances.
+ *
+ * Note alternatively you can use {@link #add(BeanQueryAdapter)} to add
+ * BeanQueryAdapter instances one at a time.
+ */
+ DatabaseBuilder setQueryAdapters(List
+ * Note alternatively you can use {@link #setPersistControllers(List)} to set
+ * all the BeanPersistController instances.
+ */
+ DatabaseBuilder add(BeanPersistController beanPersistController);
+
+ /**
+ * Register a BeanPostLoad instance.
+ *
+ * Note alternatively you can use {@link #setPostLoaders(List)} to set
+ * all the BeanPostLoad instances.
+ */
+ DatabaseBuilder add(BeanPostLoad postLoad);
+
+ /**
+ * Register a BeanPostConstructListener instance.
+ *
+ * Note alternatively you can use {@link #setPostConstructListeners(List)} to set
+ * all the BeanPostConstructListener instances.
+ */
+ DatabaseBuilder add(BeanPostConstructListener listener);
+
+ /**
+ * Set the list of BeanFindController instances.
+ */
+ DatabaseBuilder setFindControllers(List
+ * Note alternatively you can use {@link #add(BeanPersistController)} to add
+ * BeanPersistController instances one at a time.
+ */
+ DatabaseBuilder setPersistControllers(List
+ * Note alternatively you can use {@link #setPersistListeners(List)} to set
+ * all the BeanPersistListener instances.
+ */
+ DatabaseBuilder add(BeanPersistListener beanPersistListener);
+
+ /**
+ * Add a BulkTableEventListener
+ */
+ DatabaseBuilder add(BulkTableEventListener bulkTableEventListener);
+
+ /**
+ * Add a ServerConfigStartup.
+ */
+ DatabaseBuilder addServerConfigStartup(ServerConfigStartup configStartupListener);
+
+ /**
+ * Register all the BeanPersistListener instances.
+ *
+ * Note alternatively you can use {@link #add(BeanPersistListener)} to add
+ * BeanPersistListener instances one at a time.
+ */
+ DatabaseBuilder setPersistListeners(List
+ * Uses
+ * 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);
+
+ /**
+ * 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".
+ */
+ 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);
+
+ /**
+ * Controls if Ebean should ignore
+ * Normally when Ebean sees javax NotNull annotation it means that column is defined as NOT NULL.
+ * Set this to
+ * 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.
+ */
+ default DatabaseBuilder notifyL2CacheInForeground(boolean notifyL2CacheInForeground) {
+ return setNotifyL2CacheInForeground(notifyL2CacheInForeground);
+ }
+
+ /**
+ * @deprecated migrate to {@link #notifyL2CacheInForeground(boolean)}.
+ */
+ @Deprecated
+ DatabaseBuilder setNotifyL2CacheInForeground(boolean notifyL2CacheInForeground);
+
+ /**
+ * 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.
+ */
+ default DatabaseBuilder queryPlanTTLSeconds(int queryPlanTTLSeconds) {
+ return setQueryPlanTTLSeconds(queryPlanTTLSeconds);
+ }
+
+ /**
+ * @deprecated migrate to {@link #queryPlanTTLSeconds(int)}.
+ */
+ @Deprecated
+ DatabaseBuilder 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.
+ */
+ 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.
+ */
+ default DatabaseBuilder mappingLocations(List
+ * 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);
+
+ /**
+ * 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.
+ */
+ 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);
+
+ /**
+ * Include 'sql' or 'hash' in options such that they are included in the output.
+ *
+ * @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);
+
+ /**
+ * 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 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.
+ */
+ default DatabaseBuilder metricNaming(Function
+ * 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.
+ *
+ * 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.
+ *
+ * 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 tenancy catalog provider.
+ */
+ TenantCatalogProvider getTenantCatalogProvider();
+
+ /**
+ * 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 true if dirty beans are automatically persisted.
+ */
+ boolean isAutoPersistUpdates();
+
+ /**
+ * 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();
+
+ /**
+ * 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.
+ */
+ 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 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.
+ */
+ 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
+ * This is only used if classes have not been explicitly specified.
+ */
+ List
+ * 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.
+ *
+ *
+ * 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
+ * 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
+ * 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
* If you have multiple servers in different JVMs, do not share the state
* files!
*/
@@ -548,95 +550,77 @@ public class DatabaseConfig {
public DatabaseConfig() {
}
- /**
- * Get the clock used for setting the timestamps (e.g. @UpdatedTimestamp) on objects.
- */
+ @Override
+ public Database build() {
+ return DatabaseFactory.create(this);
+ }
+
+ @Override
+ public Settings settings() {
+ return this;
+ }
+
+ @Override
public Clock getClock() {
return clock;
}
- /**
- * Set the clock used for setting the timestamps (e.g. @UpdatedTimestamp) on objects.
- */
- public void setClock(final Clock clock) {
+ @Override
+ public DatabaseConfig setClock(final Clock clock) {
this.clock = clock;
+ return this;
}
- /**
- * Return the slow query time in millis.
- */
+ @Override
public long getSlowQueryMillis() {
return slowQueryMillis;
}
- /**
- * Set the slow query time in millis.
- */
- public void setSlowQueryMillis(long slowQueryMillis) {
+ @Override
+ public DatabaseConfig setSlowQueryMillis(long slowQueryMillis) {
this.slowQueryMillis = slowQueryMillis;
+ return this;
}
- /**
- * Return the slow query event listener.
- */
+ @Override
public SlowQueryListener getSlowQueryListener() {
return slowQueryListener;
}
- /**
- * Set the slow query event listener.
- */
- public void setSlowQueryListener(SlowQueryListener slowQueryListener) {
+ @Override
+ public DatabaseConfig setSlowQueryListener(SlowQueryListener slowQueryListener) {
this.slowQueryListener = slowQueryListener;
+ return this;
}
- /**
- * 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.
- */
- public void putServiceObject(String key, Object configObject) {
+ @Override
+ public DatabaseConfig putServiceObject(String key, Object configObject) {
serviceObject.put(key, configObject);
+ return this;
}
- /**
- * 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.
- * P getServiceObject(Class cls) {
+ return (P) serviceObject.get(serviceObjectKey(cls));
}
private String serviceObjectKey(Object configObject) {
@@ -648,948 +632,646 @@ public class DatabaseConfig {
return Character.toLowerCase(simpleName.charAt(0)) + simpleName.substring(1);
}
- /**
- * Used by ebean or plugins to obtain service objects.
- *
- * 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.
- */
- public void setJsonFactory(JsonFactory jsonFactory) {
+ @Override
+ public DatabaseConfig setJsonFactory(JsonFactory jsonFactory) {
this.jsonFactory = jsonFactory;
+ return this;
}
- /**
- * Return the JSON format used for DateTime types.
- */
+ @Override
public JsonConfig.DateTime getJsonDateTime() {
return jsonDateTime;
}
- /**
- * Set the JSON format to use for DateTime types.
- */
- public void setJsonDateTime(JsonConfig.DateTime jsonDateTime) {
+ @Override
+ public DatabaseConfig setJsonDateTime(JsonConfig.DateTime jsonDateTime) {
this.jsonDateTime = jsonDateTime;
+ return this;
}
- /**
- * Return the JSON format used for Date types.
- */
+ @Override
public JsonConfig.Date getJsonDate() {
return jsonDate;
}
- /**
- * Set the JSON format to use for Date types.
- */
- public void setJsonDate(JsonConfig.Date jsonDate) {
+ @Override
+ public DatabaseConfig setJsonDate(JsonConfig.Date jsonDate) {
this.jsonDate = jsonDate;
+ return this;
}
- /**
- * 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.
- */
- public void setJsonInclude(JsonConfig.Include jsonInclude) {
+ @Override
+ public DatabaseConfig setJsonInclude(JsonConfig.Include jsonInclude) {
this.jsonInclude = jsonInclude;
+ return this;
}
- /**
- * 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()
- */
- public void setJsonMutationDetection(MutationDetection jsonMutationDetection) {
+ @Override
+ public DatabaseConfig setJsonMutationDetection(MutationDetection jsonMutationDetection) {
this.jsonMutationDetection = jsonMutationDetection;
+ return this;
}
- /**
- * Return the name of the Database.
- */
+ @Override
public String getName() {
return name;
}
- /**
- * Set the name of the Database.
- */
- public void setName(String name) {
+ @Override
+ public DatabaseConfig setName(String name) {
this.name = name;
+ return this;
}
- /**
- * Return the container / clustering configuration.
- *
- * 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.
- */
- public void setRegister(boolean register) {
+ @Override
+ public DatabaseConfig setRegister(boolean register) {
this.register = register;
+ return this;
}
- /**
- * 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.
- */
- public void setDefaultServer(boolean defaultServer) {
+ @Override
+ public DatabaseConfig setDefaultServer(boolean defaultServer) {
this.defaultServer = defaultServer;
+ return this;
}
- /**
- * 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).
- */
- public void setCurrentUserProvider(CurrentUserProvider currentUserProvider) {
+ @Override
+ public DatabaseConfig setCurrentUserProvider(CurrentUserProvider currentUserProvider) {
this.currentUserProvider = currentUserProvider;
+ return this;
}
- /**
- * Return the tenancy mode used.
- */
+ @Override
public TenantMode getTenantMode() {
return tenantMode;
}
- /**
- * Set the tenancy mode to use.
- */
- public void setTenantMode(TenantMode tenantMode) {
+ @Override
+ public DatabaseConfig setTenantMode(TenantMode tenantMode) {
this.tenantMode = tenantMode;
+ return this;
}
- /**
- * Return the column name used for TenantMode.PARTITION.
- */
+ @Override
public String getTenantPartitionColumn() {
return tenantPartitionColumn;
}
- /**
- * Set the column name used for TenantMode.PARTITION.
- */
- public void setTenantPartitionColumn(String tenantPartitionColumn) {
+ @Override
+ public DatabaseConfig setTenantPartitionColumn(String tenantPartitionColumn) {
this.tenantPartitionColumn = tenantPartitionColumn;
+ return this;
}
- /**
- * Return the current tenant provider.
- */
+ @Override
public CurrentTenantProvider getCurrentTenantProvider() {
return currentTenantProvider;
}
- /**
- * Set the current tenant provider.
- */
- public void setCurrentTenantProvider(CurrentTenantProvider currentTenantProvider) {
+ @Override
+ public DatabaseConfig setCurrentTenantProvider(CurrentTenantProvider currentTenantProvider) {
this.currentTenantProvider = currentTenantProvider;
+ return this;
}
- /**
- * Return the tenancy datasource provider.
- */
+ @Override
public TenantDataSourceProvider getTenantDataSourceProvider() {
return tenantDataSourceProvider;
}
- /**
- * Set the tenancy datasource provider.
- */
- public void setTenantDataSourceProvider(TenantDataSourceProvider tenantDataSourceProvider) {
+ @Override
+ public DatabaseConfig setTenantDataSourceProvider(TenantDataSourceProvider tenantDataSourceProvider) {
this.tenantDataSourceProvider = tenantDataSourceProvider;
+ return this;
}
- /**
- * Return the tenancy schema provider.
- */
+ @Override
public TenantSchemaProvider getTenantSchemaProvider() {
return tenantSchemaProvider;
}
- /**
- * Set the tenancy schema provider.
- */
- public void setTenantSchemaProvider(TenantSchemaProvider tenantSchemaProvider) {
+ @Override
+ public DatabaseConfig setTenantSchemaProvider(TenantSchemaProvider tenantSchemaProvider) {
this.tenantSchemaProvider = tenantSchemaProvider;
+ return this;
}
- /**
- * Return the tenancy catalog provider.
- */
+ @Override
public TenantCatalogProvider getTenantCatalogProvider() {
return tenantCatalogProvider;
}
- /**
- * Set the tenancy catalog provider.
- */
- public void setTenantCatalogProvider(TenantCatalogProvider tenantCatalogProvider) {
+ @Override
+ public DatabaseConfig setTenantCatalogProvider(TenantCatalogProvider tenantCatalogProvider) {
this.tenantCatalogProvider = tenantCatalogProvider;
+ return this;
}
- /**
- * Return true if dirty beans are automatically persisted.
- */
+ @Override
public boolean isAutoPersistUpdates() {
return autoPersistUpdates;
}
- /**
- * Set to true if dirty beans are automatically persisted.
- */
- public void setAutoPersistUpdates(boolean autoPersistUpdates) {
+ @Override
+ public DatabaseConfig setAutoPersistUpdates(boolean autoPersistUpdates) {
this.autoPersistUpdates = autoPersistUpdates;
+ return this;
}
- /**
- * 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.
- */
- public void setPersistBatch(PersistBatch persistBatch) {
+ @Override
+ public DatabaseConfig setPersistBatch(PersistBatch persistBatch) {
this.persistBatch = persistBatch;
+ return this;
}
- /**
- * 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.
- */
- public void setPersistBatchOnCascade(PersistBatch persistBatchOnCascade) {
+ @Override
+ public DatabaseConfig setPersistBatchOnCascade(PersistBatch persistBatchOnCascade) {
this.persistBatchOnCascade = persistBatchOnCascade;
+ return this;
}
- /**
- * 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)}
- */
- public void setPersistBatching(boolean persistBatching) {
+ @Override
+ public DatabaseConfig setPersistBatching(boolean persistBatching) {
this.persistBatch = (persistBatching) ? PersistBatch.ALL : PersistBatch.NONE;
+ return this;
}
- /**
- * 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)
- */
- public void setPersistBatchSize(int persistBatchSize) {
+ @Override
+ public DatabaseConfig setPersistBatchSize(int persistBatchSize) {
this.persistBatchSize = persistBatchSize;
+ return this;
}
- /**
- * 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
- */
- public void setQueryBatchSize(int queryBatchSize) {
+ @Override
+ public DatabaseConfig setQueryBatchSize(int queryBatchSize) {
this.queryBatchSize = queryBatchSize;
+ return this;
}
+ @Override
public EnumType getDefaultEnumType() {
return defaultEnumType;
}
- public void setDefaultEnumType(EnumType defaultEnumType) {
+ @Override
+ public DatabaseConfig setDefaultEnumType(EnumType defaultEnumType) {
this.defaultEnumType = defaultEnumType;
+ return this;
}
- /**
- * 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)}.
- */
- public void setDisableLazyLoading(boolean disableLazyLoading) {
+ @Override
+ public DatabaseConfig setDisableLazyLoading(boolean disableLazyLoading) {
this.disableLazyLoading = disableLazyLoading;
+ return this;
}
- /**
- * 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.
- */
- public void setLazyLoadBatchSize(int lazyLoadBatchSize) {
+ @Override
+ public DatabaseConfig setLazyLoadBatchSize(int lazyLoadBatchSize) {
this.lazyLoadBatchSize = lazyLoadBatchSize;
+ return this;
}
- /**
- * 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).
- */
- public void setDatabaseSequenceBatchSize(int databaseSequenceBatchSize) {
+ @Override
+ public DatabaseConfig setDatabaseSequenceBatchSize(int databaseSequenceBatchSize) {
platformConfig.setDatabaseSequenceBatchSize(databaseSequenceBatchSize);
+ return this;
}
- /**
- * Return the default JDBC fetchSize hint for findList queries.
- */
+ @Override
public int getJdbcFetchSizeFindList() {
return jdbcFetchSizeFindList;
}
- /**
- * Set the default JDBC fetchSize hint for findList queries.
- */
- public void setJdbcFetchSizeFindList(int jdbcFetchSizeFindList) {
+ @Override
+ public DatabaseConfig setJdbcFetchSizeFindList(int jdbcFetchSizeFindList) {
this.jdbcFetchSizeFindList = jdbcFetchSizeFindList;
+ return this;
}
- /**
- * 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.
- */
- public void setJdbcFetchSizeFindEach(int jdbcFetchSizeFindEach) {
+ @Override
+ public DatabaseConfig setJdbcFetchSizeFindEach(int jdbcFetchSizeFindEach) {
this.jdbcFetchSizeFindEach = jdbcFetchSizeFindEach;
+ return this;
}
- /**
- * 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.
- */
- public void setChangeLogPrepare(ChangeLogPrepare changeLogPrepare) {
+ @Override
+ public DatabaseConfig setChangeLogPrepare(ChangeLogPrepare changeLogPrepare) {
this.changeLogPrepare = changeLogPrepare;
+ return this;
}
- /**
- * 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.
- */
- public void setChangeLogListener(ChangeLogListener changeLogListener) {
+ @Override
+ public DatabaseConfig setChangeLogListener(ChangeLogListener changeLogListener) {
this.changeLogListener = changeLogListener;
+ return this;
}
- /**
- * 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.
- */
- public void setChangeLogRegister(ChangeLogRegister changeLogRegister) {
+ @Override
+ public DatabaseConfig setChangeLogRegister(ChangeLogRegister changeLogRegister) {
this.changeLogRegister = changeLogRegister;
+ return this;
}
- /**
- * 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.
- */
- public void setChangeLogIncludeInserts(boolean changeLogIncludeInserts) {
+ @Override
+ public DatabaseConfig setChangeLogIncludeInserts(boolean changeLogIncludeInserts) {
this.changeLogIncludeInserts = changeLogIncludeInserts;
+ return this;
}
- /**
- * 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).
- */
- public void setChangeLogAsync(boolean changeLogAsync) {
+ @Override
+ public DatabaseConfig setChangeLogAsync(boolean changeLogAsync) {
this.changeLogAsync = changeLogAsync;
+ return this;
}
- /**
- * 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).
- */
- public void setReadAuditLogger(ReadAuditLogger readAuditLogger) {
+ @Override
+ public DatabaseConfig setReadAuditLogger(ReadAuditLogger readAuditLogger) {
this.readAuditLogger = readAuditLogger;
+ return this;
}
- /**
- * 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.
- */
- public void setReadAuditPrepare(ReadAuditPrepare readAuditPrepare) {
+ @Override
+ public DatabaseConfig setReadAuditPrepare(ReadAuditPrepare readAuditPrepare) {
this.readAuditPrepare = readAuditPrepare;
+ return this;
}
- /**
- * Return the configuration for profiling.
- */
+ @Override
public ProfilingConfig getProfilingConfig() {
return profilingConfig;
}
- /**
- * Set the configuration for profiling.
- */
- public void setProfilingConfig(ProfilingConfig profilingConfig) {
+ @Override
+ public DatabaseConfig setProfilingConfig(ProfilingConfig profilingConfig) {
this.profilingConfig = profilingConfig;
+ return this;
}
- /**
- * 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:
- *
- * 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.
- */
- public void setDataTimeZone(String dataTimeZone) {
+ @Override
+ public DatabaseConfig setDataTimeZone(String dataTimeZone) {
this.dataTimeZone = dataTimeZone;
+ return this;
}
- /**
- * 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.
- */
- public void setAsOfViewSuffix(String asOfViewSuffix) {
+ @Override
+ public DatabaseConfig setAsOfViewSuffix(String asOfViewSuffix) {
this.asOfViewSuffix = asOfViewSuffix;
+ return this;
}
- /**
- * 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.
- */
- public void setAsOfSysPeriod(String asOfSysPeriod) {
+ @Override
+ public DatabaseConfig setAsOfSysPeriod(String asOfSysPeriod) {
this.asOfSysPeriod = asOfSysPeriod;
+ return this;
}
- /**
- * Return the history table suffix (defaults to _history).
- */
+ @Override
public String getHistoryTableSuffix() {
return historyTableSuffix;
}
- /**
- * Set the history table suffix.
- */
- public void setHistoryTableSuffix(String historyTableSuffix) {
+ @Override
+ public DatabaseConfig setHistoryTableSuffix(String historyTableSuffix) {
this.historyTableSuffix = historyTableSuffix;
+ return this;
}
- /**
- * 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.
- */
- public void setUseJtaTransactionManager(boolean useJtaTransactionManager) {
+ @Override
+ public DatabaseConfig setUseJtaTransactionManager(boolean useJtaTransactionManager) {
this.useJtaTransactionManager = useJtaTransactionManager;
+ return this;
}
- /**
- * Return the external transaction manager.
- */
+ @Override
public ExternalTransactionManager getExternalTransactionManager() {
return externalTransactionManager;
}
- /**
- * Set the external transaction manager.
- */
- public void setExternalTransactionManager(ExternalTransactionManager externalTransactionManager) {
+ @Override
+ public DatabaseConfig setExternalTransactionManager(ExternalTransactionManager externalTransactionManager) {
this.externalTransactionManager = externalTransactionManager;
+ return this;
}
- /**
- * Return the ServerCachePlugin.
- */
+ @Override
public ServerCachePlugin getServerCachePlugin() {
return serverCachePlugin;
}
- /**
- * Set the ServerCachePlugin to use.
- */
- public void setServerCachePlugin(ServerCachePlugin serverCachePlugin) {
+ @Override
+ public DatabaseConfig setServerCachePlugin(ServerCachePlugin serverCachePlugin) {
this.serverCachePlugin = serverCachePlugin;
+ return this;
}
- /**
- * 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.
- */
- public void setEagerFetchLobs(boolean eagerFetchLobs) {
+ @Override
+ public DatabaseConfig setEagerFetchLobs(boolean eagerFetchLobs) {
this.eagerFetchLobs = eagerFetchLobs;
+ return this;
}
- /**
- * 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.
- */
- public void setMaxCallStack(int maxCallStack) {
+ @Override
+ public DatabaseConfig setMaxCallStack(int maxCallStack) {
this.maxCallStack = maxCallStack;
+ return this;
}
- /**
- * 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.
- */
- public void setTransactionRollbackOnChecked(boolean transactionRollbackOnChecked) {
+ @Override
+ public DatabaseConfig setTransactionRollbackOnChecked(boolean transactionRollbackOnChecked) {
this.transactionRollbackOnChecked = transactionRollbackOnChecked;
+ return this;
}
- /**
- * Return the Background executor schedule pool size. Defaults to 1.
- */
+ @Override
public int getBackgroundExecutorSchedulePoolSize() {
return backgroundExecutorSchedulePoolSize;
}
- /**
- * Set the Background executor schedule pool size.
- */
- public void setBackgroundExecutorSchedulePoolSize(int backgroundExecutorSchedulePoolSize) {
+ @Override
+ public DatabaseConfig setBackgroundExecutorSchedulePoolSize(int backgroundExecutorSchedulePoolSize) {
this.backgroundExecutorSchedulePoolSize = backgroundExecutorSchedulePoolSize;
+ return this;
}
- /**
- * 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.
- */
- public void setBackgroundExecutorShutdownSecs(int backgroundExecutorShutdownSecs) {
+ @Override
+ public DatabaseConfig setBackgroundExecutorShutdownSecs(int backgroundExecutorShutdownSecs) {
this.backgroundExecutorShutdownSecs = backgroundExecutorShutdownSecs;
+ return this;
}
- /**
- * 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.
- */
- public void setBackgroundExecutorWrapper(BackgroundExecutorWrapper backgroundExecutorWrapper) {
+ @Override
+ public DatabaseConfig setBackgroundExecutorWrapper(BackgroundExecutorWrapper backgroundExecutorWrapper) {
this.backgroundExecutorWrapper = backgroundExecutorWrapper;
+ return this;
}
- /**
- * Return the L2 cache default max size.
- */
+ @Override
public int getCacheMaxSize() {
return cacheMaxSize;
}
- /**
- * Set the L2 cache default max size.
- */
- public void setCacheMaxSize(int cacheMaxSize) {
+ @Override
+ public DatabaseConfig setCacheMaxSize(int cacheMaxSize) {
this.cacheMaxSize = cacheMaxSize;
+ return this;
}
- /**
- * 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.
- */
- public void setCacheMaxIdleTime(int cacheMaxIdleTime) {
+ @Override
+ public DatabaseConfig setCacheMaxIdleTime(int cacheMaxIdleTime) {
this.cacheMaxIdleTime = cacheMaxIdleTime;
+ return this;
}
- /**
- * 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.
- */
- public void setCacheMaxTimeToLive(int cacheMaxTimeToLive) {
+ @Override
+ public DatabaseConfig setCacheMaxTimeToLive(int cacheMaxTimeToLive) {
this.cacheMaxTimeToLive = cacheMaxTimeToLive;
+ return this;
}
- /**
- * Return the L2 query cache default max size.
- */
+ @Override
public int getQueryCacheMaxSize() {
return queryCacheMaxSize;
}
- /**
- * Set the L2 query cache default max size.
- */
- public void setQueryCacheMaxSize(int queryCacheMaxSize) {
+ @Override
+ public DatabaseConfig setQueryCacheMaxSize(int queryCacheMaxSize) {
this.queryCacheMaxSize = queryCacheMaxSize;
+ return this;
}
- /**
- * 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.
- */
- public void setQueryCacheMaxIdleTime(int queryCacheMaxIdleTime) {
+ @Override
+ public DatabaseConfig setQueryCacheMaxIdleTime(int queryCacheMaxIdleTime) {
this.queryCacheMaxIdleTime = queryCacheMaxIdleTime;
+ return this;
}
- /**
- * 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.
- */
- public void setQueryCacheMaxTimeToLive(int queryCacheMaxTimeToLive) {
+ @Override
+ public DatabaseConfig setQueryCacheMaxTimeToLive(int queryCacheMaxTimeToLive) {
this.queryCacheMaxTimeToLive = queryCacheMaxTimeToLive;
+ return this;
}
- /**
- * 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.
- */
- public void setNamingConvention(NamingConvention namingConvention) {
+ @Override
+ public DatabaseConfig setNamingConvention(NamingConvention namingConvention) {
this.namingConvention = namingConvention;
+ return this;
}
- /**
- * 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).
- */
- public void setAllQuotedIdentifiers(boolean allQuotedIdentifiers) {
+ @Override
+ public DatabaseConfig setAllQuotedIdentifiers(boolean allQuotedIdentifiers) {
platformConfig.setAllQuotedIdentifiers(allQuotedIdentifiers);
if (allQuotedIdentifiers) {
adjustNamingConventionForAllQuoted();
}
+ return this;
}
private void adjustNamingConventionForAllQuoted() {
@@ -1599,423 +1281,266 @@ 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).
- */
- public void setDocStoreOnly(boolean docStoreOnly) {
+ @Override
+ public DatabaseConfig setDocStoreOnly(boolean docStoreOnly) {
this.docStoreOnly = docStoreOnly;
+ return this;
}
- /**
- * Return the configuration for the ElasticSearch integration.
- */
+ @Override
public DocStoreConfig getDocStoreConfig() {
return docStoreConfig;
}
- /**
- * Set the configuration for the ElasticSearch integration.
- */
- public void setDocStoreConfig(DocStoreConfig docStoreConfig) {
+ @Override
+ public DatabaseConfig setDocStoreConfig(DocStoreConfig docStoreConfig) {
this.docStoreConfig = docStoreConfig;
+ return this;
}
- /**
- * 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.
- */
- public void setConstraintNaming(DbConstraintNaming constraintNaming) {
+ @Override
+ public DatabaseConfig setConstraintNaming(DbConstraintNaming constraintNaming) {
platformConfig.setConstraintNaming(constraintNaming);
+ return this;
}
- /**
- * Return the configuration for AutoTune.
- */
+ @Override
public AutoTuneConfig getAutoTuneConfig() {
return autoTuneConfig;
}
- /**
- * Set the configuration for AutoTune.
- */
- public void setAutoTuneConfig(AutoTuneConfig autoTuneConfig) {
+ @Override
+ public DatabaseConfig setAutoTuneConfig(AutoTuneConfig autoTuneConfig) {
this.autoTuneConfig = autoTuneConfig;
+ return this;
}
- /**
- * 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.
- */
- public void setSkipDataSourceCheck(boolean skipDataSourceCheck) {
+ @Override
+ public DatabaseConfig setSkipDataSourceCheck(boolean skipDataSourceCheck) {
this.skipDataSourceCheck = skipDataSourceCheck;
+ return this;
}
- /**
- * Return the DataSource.
- */
+ @Override
public DataSource getDataSource() {
return dataSource;
}
- /**
- * Set a DataSource.
- */
- public void setDataSource(DataSource dataSource) {
+ @Override
+ public DatabaseConfig setDataSource(DataSource dataSource) {
this.dataSource = dataSource;
+ return this;
}
- /**
- * 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.
- */
- public void setReadOnlyDataSource(DataSource readOnlyDataSource) {
+ @Override
+ public DatabaseConfig setReadOnlyDataSource(DataSource readOnlyDataSource) {
this.readOnlyDataSource = readOnlyDataSource;
+ return this;
}
- /**
- * 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.
- */
- public void setDataSourceConfig(DataSourceBuilder dataSourceConfig) {
+ @Override
+ public DatabaseConfig setDataSourceConfig(DataSourceBuilder dataSourceConfig) {
this.dataSourceConfig = dataSourceConfig;
+ return this;
}
- /**
- * 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.
- */
- public void setAutoReadOnlyDataSource(boolean autoReadOnlyDataSource) {
+ @Override
+ public DatabaseConfig setAutoReadOnlyDataSource(boolean autoReadOnlyDataSource) {
this.autoReadOnlyDataSource = autoReadOnlyDataSource;
+ return this;
}
- /**
- * 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.
- */
- public void setReadOnlyDataSourceConfig(DataSourceBuilder readOnlyDataSourceConfig) {
+ @Override
+ public DatabaseConfig setReadOnlyDataSourceConfig(DataSourceBuilder readOnlyDataSourceConfig) {
this.readOnlyDataSourceConfig = readOnlyDataSourceConfig;
+ return this;
}
- /**
- * 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").
- */
- public void setDatabaseBooleanTrue(String databaseTrue) {
+ @Override
+ public DatabaseConfig setDatabaseBooleanTrue(String databaseTrue) {
platformConfig.setDatabaseBooleanTrue(databaseTrue);
+ return this;
}
- /**
- * 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").
- */
- public void setDatabaseBooleanFalse(String databaseFalse) {
+ @Override
+ public DatabaseConfig setDatabaseBooleanFalse(String databaseFalse) {
this.platformConfig.setDatabaseBooleanFalse(databaseFalse);
+ return this;
}
- /**
- * 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.
- */
- public void setDatabaseSequenceBatch(int databaseSequenceBatchSize) {
+ @Override
+ public DatabaseConfig setDatabaseSequenceBatch(int databaseSequenceBatchSize) {
this.platformConfig.setDatabaseSequenceBatchSize(databaseSequenceBatchSize);
+ return this;
}
- /**
- * 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.
- */
- public void setDatabasePlatformName(String databasePlatformName) {
+ @Override
+ public DatabaseConfig setDatabasePlatformName(String databasePlatformName) {
this.databasePlatformName = databasePlatformName;
+ return this;
}
- /**
- * 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.
- */
- public void setDatabasePlatform(DatabasePlatform databasePlatform) {
+ @Override
+ public DatabaseConfig setDatabasePlatform(DatabasePlatform databasePlatform) {
this.databasePlatform = databasePlatform;
+ return this;
}
- /**
- * Return the preferred DB platform IdType.
- */
+ @Override
public IdType getIdType() {
return platformConfig.getIdType();
}
- /**
- * Set the preferred DB platform IdType.
- */
- public void setIdType(IdType idType) {
+ @Override
+ public DatabaseConfig setIdType(IdType idType) {
this.platformConfig.setIdType(idType);
+ return this;
}
- /**
- * 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:
- *
- *
- * 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.
- */
- public void setEncryptDeployManager(EncryptDeployManager encryptDeployManager) {
+ @Override
+ public DatabaseConfig setEncryptDeployManager(EncryptDeployManager encryptDeployManager) {
this.encryptDeployManager = encryptDeployManager;
+ return this;
}
- /**
- * 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.
- */
- public void setEncryptor(Encryptor encryptor) {
+ @Override
+ public DatabaseConfig setEncryptor(Encryptor encryptor) {
this.encryptor = encryptor;
+ return this;
}
- /**
- * 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.
- */
- public void setDbOffline(boolean dbOffline) {
+ @Override
+ public DatabaseConfig setDbOffline(boolean dbOffline) {
this.dbOffline = dbOffline;
+ return this;
}
- /**
- * 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)
- */
- public void setDbEncrypt(DbEncrypt dbEncrypt) {
+ @Override
+ public DatabaseConfig setDbEncrypt(DbEncrypt dbEncrypt) {
this.dbEncrypt = dbEncrypt;
+ return this;
}
- /**
- * 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).
- */
- public void setPlatformConfig(PlatformConfig platformConfig) {
+ @Override
+ public DatabaseConfig setPlatformConfig(PlatformConfig platformConfig) {
this.platformConfig = platformConfig;
+ return this;
}
- /**
- * Set the DB type used to store UUID.
- */
- public void setDbUuid(PlatformConfig.DbUuid dbUuid) {
+ @Override
+ public DatabaseConfig setDbUuid(PlatformConfig.DbUuid dbUuid) {
this.platformConfig.setDbUuid(dbUuid);
+ return this;
}
- /**
- * Returns the UUID version mode.
- */
+ @Override
public UuidVersion getUuidVersion() {
return uuidVersion;
}
- /**
- * Sets the UUID version mode.
- */
- public void setUuidVersion(UuidVersion uuidVersion) {
+ @Override
+ public DatabaseConfig setUuidVersion(UuidVersion uuidVersion) {
this.uuidVersion = uuidVersion;
+ return this;
}
- /**
- * Return the UUID state file.
- */
+ @Override
public String getUuidStateFile() {
if (uuidStateFile == null || uuidStateFile.isEmpty()) {
// by default, add servername...
@@ -2029,194 +1554,131 @@ public class DatabaseConfig {
return uuidStateFile;
}
- /**
- * Set the UUID state file.
- */
- public void setUuidStateFile(String uuidStateFile) {
+ @Override
+ public DatabaseConfig setUuidStateFile(String uuidStateFile) {
this.uuidStateFile = uuidStateFile;
+ return this;
}
- /**
- * Returns the V1-UUID-NodeId
- */
+ @Override
public String getUuidNodeId() {
return uuidNodeId;
}
- /**
- * Sets the V1-UUID-NodeId.
- */
- public void setUuidNodeId(String uuidNodeId) {
+ @Override
+ public DatabaseConfig setUuidNodeId(String uuidNodeId) {
this.uuidNodeId = uuidNodeId;
+ return this;
}
- /**
- * 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.
- */
- public void setLocalTimeWithNanos(boolean localTimeWithNanos) {
+ @Override
+ public DatabaseConfig setLocalTimeWithNanos(boolean localTimeWithNanos) {
this.localTimeWithNanos = localTimeWithNanos;
+ return this;
}
- /**
- * 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).
- */
- public void setDurationWithNanos(boolean durationWithNanos) {
+ @Override
+ public DatabaseConfig setDurationWithNanos(boolean durationWithNanos) {
this.durationWithNanos = durationWithNanos;
+ return this;
}
- /**
- * 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.
- */
- public void setRunMigration(boolean runMigration) {
+ @Override
+ public DatabaseConfig setRunMigration(boolean runMigration) {
this.runMigration = runMigration;
+ return this;
}
- /**
- * 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.
- */
- public void setDdlGenerate(boolean ddlGenerate) {
+ @Override
+ public DatabaseConfig setDdlGenerate(boolean ddlGenerate) {
this.ddlGenerate = ddlGenerate;
+ return this;
}
- /**
- * 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.
- */
- public void setDdlRun(boolean ddlRun) {
+ @Override
+ public DatabaseConfig setDdlRun(boolean ddlRun) {
this.ddlRun = ddlRun;
+ return this;
}
- /**
- * 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.
- */
- public void setDdlExtra(boolean ddlExtra) {
+ @Override
+ public DatabaseConfig setDdlExtra(boolean ddlExtra) {
this.ddlExtra = ddlExtra;
+ return this;
}
- /**
- * 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.
- */
- public void setDdlCreateOnly(boolean ddlCreateOnly) {
+ @Override
+ public DatabaseConfig setDdlCreateOnly(boolean ddlCreateOnly) {
this.ddlCreateOnly = ddlCreateOnly;
+ return this;
}
- /**
- * 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.
- */
- public void setDdlSeedSql(String ddlSeedSql) {
+ @Override
+ public DatabaseConfig setDdlSeedSql(String ddlSeedSql) {
this.ddlSeedSql = ddlSeedSql;
+ return this;
}
- /**
- * 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.
- */
- public void setDdlInitSql(String ddlInitSql) {
+ @Override
+ public DatabaseConfig setDdlInitSql(String ddlInitSql) {
this.ddlInitSql = ddlInitSql;
+ return this;
}
- /**
- * 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.
- */
- public void setDdlHeader(String ddlHeader) {
+ @Override
+ public DatabaseConfig setDdlHeader(String ddlHeader) {
this.ddlHeader = ddlHeader;
+ return this;
}
- /**
- * 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,544 +1688,339 @@ 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.
- */
- public void setDdlStrictMode(boolean ddlStrictMode) {
+ @Override
+ public DatabaseConfig setDdlStrictMode(boolean ddlStrictMode) {
this.ddlStrictMode = ddlStrictMode;
+ return this;
}
- /**
- * 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.
- */
- public void setDdlPlaceholders(String ddlPlaceholders) {
+ @Override
+ public DatabaseConfig setDdlPlaceholders(String ddlPlaceholders) {
this.ddlPlaceholders = ddlPlaceholders;
+ return this;
}
- /**
- * Return a map of placeholder values that are substituted in DDL scripts.
- */
+ @Override
public Map
- * 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.
- */
- public void addClass(Class> cls) {
+ @Override
+ public DatabaseConfig addClass(Class> cls) {
classes.add(cls);
+ return this;
}
- /**
- * Register all the classes (typically entity classes).
- */
- public void addAll(Collection
- * This is only used if classes have not been explicitly specified.
- */
- public void addPackage(String packageName) {
+ @Override
+ public DatabaseConfig addPackage(String packageName) {
packages.add(packageName);
+ return this;
}
- /**
- * Return packages to search for entities via class path search.
- *
- * This is only used if classes have not been explicitly specified.
- */
+ @Override
public List
- * This is only used if classes have not been explicitly specified.
- */
- public void setPackages(List
- * 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)}.
+ * Leaving void for spring xml wiring for now.
*/
public void setClasses(Collection
- * 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
- * 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.
- *
- *
- * This mode can be explicitly set per transaction.
- *
- * @see Transaction#setUpdateAllLoadedProperties(boolean)
- */
- public void setUpdateAllPropertiesInBatch(boolean updateAllPropertiesInBatch) {
+ @Override
+ public DatabaseConfig setUpdateAllPropertiesInBatch(boolean updateAllPropertiesInBatch) {
this.updateAllPropertiesInBatch = updateAllPropertiesInBatch;
+ return this;
}
- /**
- * Returns the resource directory.
- */
+ @Override
public String getResourceDirectory() {
return resourceDirectory;
}
- /**
- * Sets the resource directory.
- */
- public void setResourceDirectory(String resourceDirectory) {
+ @Override
+ public DatabaseConfig setResourceDirectory(String resourceDirectory) {
this.resourceDirectory = resourceDirectory;
+ return this;
}
- /**
- * Add a custom type mapping.
- *
- *
- *
- * Note alternatively you can use {@link #setQueryAdapters(List)} to set all
- * the BeanQueryAdapter instances.
- */
- public void add(BeanQueryAdapter beanQueryAdapter) {
+ @Override
+ public DatabaseConfig add(BeanQueryAdapter beanQueryAdapter) {
queryAdapters.add(beanQueryAdapter);
+ return this;
}
- /**
- * Return the BeanQueryAdapter instances.
- */
+ @Override
public List
- * Note alternatively you can use {@link #add(BeanQueryAdapter)} to add
- * BeanQueryAdapter instances one at a time.
- */
- public void setQueryAdapters(List
- * Note alternatively you can use {@link #setPersistControllers(List)} to set
- * all the BeanPersistController instances.
- */
- public void add(BeanPersistController beanPersistController) {
+ @Override
+ public DatabaseConfig add(BeanPersistController beanPersistController) {
persistControllers.add(beanPersistController);
+ return this;
}
- /**
- * Register a BeanPostLoad instance.
- *
- * Note alternatively you can use {@link #setPostLoaders(List)} to set
- * all the BeanPostLoad instances.
- */
- public void add(BeanPostLoad postLoad) {
+ @Override
+ public DatabaseConfig add(BeanPostLoad postLoad) {
postLoaders.add(postLoad);
+ return this;
}
- /**
- * Register a BeanPostConstructListener instance.
- *
- * Note alternatively you can use {@link #setPostConstructListeners(List)} to set
- * all the BeanPostConstructListener instances.
- */
- public void add(BeanPostConstructListener listener) {
+ @Override
+ public DatabaseConfig add(BeanPostConstructListener listener) {
postConstructListeners.add(listener);
+ return this;
}
- /**
- * Return the list of BeanFindController instances.
- */
+ @Override
public List
- * Note alternatively you can use {@link #add(BeanPersistController)} to add
- * BeanPersistController instances one at a time.
- */
- public void setPersistControllers(List
- * Note alternatively you can use {@link #setPersistListeners(List)} to set
- * all the BeanPersistListener instances.
- */
- public void add(BeanPersistListener beanPersistListener) {
+ @Override
+ public DatabaseConfig add(BeanPersistListener beanPersistListener) {
persistListeners.add(beanPersistListener);
+ return this;
}
- /**
- * Return the BeanPersistListener instances.
- */
+ @Override
public List
- * Note alternatively you can use {@link #add(BeanPersistListener)} to add
- * BeanPersistListener instances one at a time.
- */
- public void setPersistListeners(List
- * Uses
- * 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.
- */
- public void setObjectMapper(Object objectMapper) {
+ @Override
+ public DatabaseConfig setObjectMapper(Object objectMapper) {
this.objectMapper = objectMapper;
+ return this;
}
- /**
- * 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".
- */
- public void setExpressionEqualsWithNullAsNoop(boolean expressionEqualsWithNullAsNoop) {
+ @Override
+ public DatabaseConfig setExpressionEqualsWithNullAsNoop(boolean expressionEqualsWithNullAsNoop) {
this.expressionEqualsWithNullAsNoop = expressionEqualsWithNullAsNoop;
+ return this;
}
- /**
- * 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).
- */
- public void setExpressionNativeIlike(boolean expressionNativeIlike) {
+ @Override
+ public DatabaseConfig setExpressionNativeIlike(boolean expressionNativeIlike) {
this.expressionNativeIlike = expressionNativeIlike;
+ return this;
}
- /**
- * Return the enabled L2 cache regions.
- */
+ @Override
public String getEnabledL2Regions() {
return enabledL2Regions;
}
- /**
- * Set the enabled L2 cache regions (comma delimited).
- */
- public void setEnabledL2Regions(String enabledL2Regions) {
+ @Override
+ public DatabaseConfig setEnabledL2Regions(String enabledL2Regions) {
this.enabledL2Regions = enabledL2Regions;
+ return this;
}
- /**
- * 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.
- */
- public void setDisableL2Cache(boolean disableL2Cache) {
+ @Override
+ public DatabaseConfig setDisableL2Cache(boolean disableL2Cache) {
this.disableL2Cache = disableL2Cache;
+ return this;
}
- /**
- * 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.
- */
- public void setLocalOnlyL2Cache(boolean localOnlyL2Cache) {
+ @Override
+ public DatabaseConfig setLocalOnlyL2Cache(boolean localOnlyL2Cache) {
this.localOnlyL2Cache = localOnlyL2Cache;
+ return this;
}
- /**
- * Returns if we use javax.validation.constraints.NotNull
- */
+ @Override
public boolean isUseValidationNotNull() {
return useValidationNotNull;
}
- /**
- * Controls if Ebean should ignore
- * Normally when Ebean sees javax NotNull annotation it means that column is defined as NOT NULL.
- * Set this to
- * 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.
- */
- public void setNotifyL2CacheInForeground(boolean notifyL2CacheInForeground) {
+ @Override
+ public DatabaseConfig setNotifyL2CacheInForeground(boolean notifyL2CacheInForeground) {
this.notifyL2CacheInForeground = notifyL2CacheInForeground;
+ return this;
}
- /**
- * 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.
- */
- public void setQueryPlanTTLSeconds(int queryPlanTTLSeconds) {
+ @Override
+ public DatabaseConfig setQueryPlanTTLSeconds(int queryPlanTTLSeconds) {
this.queryPlanTTLSeconds = queryPlanTTLSeconds;
+ return this;
}
- /**
- * 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,194 +2388,137 @@ public class DatabaseConfig {
return config;
}
- /**
- * Add a mapping location to search for xml mapping via class path search.
- */
- public void addMappingLocation(String mappingLocation) {
+ @Override
+ public DatabaseConfig addMappingLocation(String mappingLocation) {
if (mappingLocations == null) {
mappingLocations = new ArrayList<>();
}
mappingLocations.add(mappingLocation);
+ return this;
}
- /**
- * Return mapping locations to search for xml mapping via class path search.
- */
+ @Override
public List
- * This is only used if classes have not been explicitly specified.
- */
- public void setMappingLocations(List
- * Queries executing slower than this will have bind values captured such that later
- * the query plan can be captured and reported.
- */
- public void setQueryPlanThresholdMicros(long queryPlanThresholdMicros) {
+ @Override
+ public DatabaseConfig setQueryPlanThresholdMicros(long queryPlanThresholdMicros) {
this.queryPlanThresholdMicros = queryPlanThresholdMicros;
+ return this;
}
- /**
- * 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.
- */
- public void setQueryPlanCapture(boolean queryPlanCapture) {
+ @Override
+ public DatabaseConfig setQueryPlanCapture(boolean queryPlanCapture) {
this.queryPlanCapture = queryPlanCapture;
+ return this;
}
- /**
- * Return the frequency to capture query plans.
- */
+ @Override
public long getQueryPlanCapturePeriodSecs() {
return queryPlanCapturePeriodSecs;
}
- /**
- * Set the frequency in seconds to capture query plans.
- */
- public void setQueryPlanCapturePeriodSecs(long queryPlanCapturePeriodSecs) {
+ @Override
+ public DatabaseConfig setQueryPlanCapturePeriodSecs(long queryPlanCapturePeriodSecs) {
this.queryPlanCapturePeriodSecs = queryPlanCapturePeriodSecs;
+ return this;
}
- /**
- * 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.
- */
- public void setQueryPlanCaptureMaxTimeMillis(long queryPlanCaptureMaxTimeMillis) {
+ @Override
+ public DatabaseConfig setQueryPlanCaptureMaxTimeMillis(long queryPlanCaptureMaxTimeMillis) {
this.queryPlanCaptureMaxTimeMillis = queryPlanCaptureMaxTimeMillis;
+ return this;
}
- /**
- * 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.
- */
- public void setQueryPlanCaptureMaxCount(int queryPlanCaptureMaxCount) {
+ @Override
+ public DatabaseConfig setQueryPlanCaptureMaxCount(int queryPlanCaptureMaxCount) {
this.queryPlanCaptureMaxCount = queryPlanCaptureMaxCount;
+ return this;
}
- /**
- * Return the listener used to process captured query plans.
- */
+ @Override
public QueryPlanListener getQueryPlanListener() {
return queryPlanListener;
}
- /**
- * Set the listener used to process captured query plans.
- */
- public void setQueryPlanListener(QueryPlanListener queryPlanListener) {
+ @Override
+ public DatabaseConfig setQueryPlanListener(QueryPlanListener queryPlanListener) {
this.queryPlanListener = queryPlanListener;
+ return this;
}
- /**
- * 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.
- */
- public void setDumpMetricsOnShutdown(boolean dumpMetricsOnShutdown) {
+ @Override
+ public DatabaseConfig setDumpMetricsOnShutdown(boolean dumpMetricsOnShutdown) {
this.dumpMetricsOnShutdown = dumpMetricsOnShutdown;
+ return this;
}
- /**
- * 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"
- */
- public void setDumpMetricsOptions(String dumpMetricsOptions) {
+ @Override
+ public DatabaseConfig setDumpMetricsOptions(String dumpMetricsOptions) {
this.dumpMetricsOptions = dumpMetricsOptions;
+ return this;
}
- /**
- * 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,34 +2526,28 @@ 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.
- */
- public void setLoadModuleInfo(boolean loadModuleInfo) {
+ @Override
+ public DatabaseConfig setLoadModuleInfo(boolean loadModuleInfo) {
this.loadModuleInfo = loadModuleInfo;
+ return this;
}
- /**
- * Return the naming convention to apply to metrics names.
- */
+ @Override
public Function
@@ -35,5 +37,5 @@ public interface DatabaseConfigProvider {
* Typically we explicitly register entity bean classes and thus avoid classpath scanning.
* {@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.
+ */
+ DatabaseBuilder 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
+ */
+ DatabaseBuilder addCustomMapping(DbType type, String columnDefinition);
+
+ /**
+ * Register a BeanQueryAdapter instance.
+ * avaje-config to load configuration properties. Goto https://avaje.io/config
+ * for detail on how and where properties are loaded from.
+ */
+ DatabaseBuilder loadFromProperties();
+
+ /**
+ * Load the settings from the given properties
+ */
+ DatabaseBuilder loadFromProperties(Properties properties);
+
+ /**
+ * Set the Jackson ObjectMapper.
+ * &x64;javax.validation.contstraints.NotNull or
+ * &x64;jakarta.validation.contstraints.NotNull
+ * with respect to generating a NOT NULL column.
+ * 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);
+
+ /**
+ * Set this to true to run L2 cache notification in the foreground.
+ * @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);
+
+ /**
+ * Set the query plan collection threshold in microseconds.
+ * {@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")
+ {@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()}.
+ * @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.
+ *
- *
- */
- public {@code
- *
- * JedisPool jedisPool = ..
- *
- * config.putServiceObject(jedisPool);
- *
- * }
- */
- public void putServiceObject(Object configObject) {
+ @Override
+ public DatabaseConfig putServiceObject(Object configObject) {
String key = serviceObjectKey(configObject);
serviceObject.put(key, configObject);
+ return this;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public {@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")
- public
- *
- */
- public void setDbSchema(String dbSchema) {
+ @Override
+ public DatabaseConfig setDbSchema(String dbSchema) {
this.dbSchema = dbSchema;
+ return this;
}
- /**
- * Return the Geometry SRID.
- */
+ @Override
public int getGeometrySRID() {
return platformConfig.getGeometrySRID();
}
- /**
- * Set the Geometry SRID.
- */
- public void setGeometrySRID(int geometrySRID) {
+ @Override
+ public DatabaseConfig setGeometrySRID(int geometrySRID) {
platformConfig.setGeometrySRID(geometrySRID);
+ return this;
}
- /**
- * Return the time zone to use when reading/writing Timestamps via JDBC.
- * {@code
- * # set via ebean.properties
- * ebean.encryptKeyManager=org.avaje.tests.basic.encrypt.BasicEncyptKeyManager
- * }
- */
- public void setEncryptKeyManager(EncryptKeyManager encryptKeyManager) {
+ @Override
+ public DatabaseConfig setEncryptKeyManager(EncryptKeyManager encryptKeyManager) {
this.encryptKeyManager = encryptKeyManager;
+ return this;
}
- /**
- * Return the EncryptDeployManager.
- * {@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.
- */
- public void setSkipCacheAfterWrite(boolean skipCacheAfterWrite) {
+ @Override
+ public DatabaseConfig setSkipCacheAfterWrite(boolean skipCacheAfterWrite) {
this.skipCacheAfterWrite = skipCacheAfterWrite;
+ return this;
}
- /**
- * 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.
- * {@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.
- */
- public void addCustomMapping(DbType type, String columnDefinition, Platform platform) {
+ @Override
+ public DatabaseConfig addCustomMapping(DbType type, String columnDefinition, Platform platform) {
platformConfig.addCustomMapping(type, columnDefinition, platform);
+ return this;
}
- /**
- * 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
- */
- public void addCustomMapping(DbType type, String columnDefinition) {
+ @Override
+ public DatabaseConfig addCustomMapping(DbType type, String columnDefinition) {
platformConfig.addCustomMapping(type, columnDefinition);
+ return this;
}
- /**
- * Register a BeanQueryAdapter instance.
- * avaje-config to load configuration properties. Goto https://avaje.io/config
- * for detail on how and where properties are loaded from.
- */
- public void loadFromProperties() {
+ @Override
+ public DatabaseConfig loadFromProperties() {
this.properties = Config.asProperties();
configureFromProperties();
+ return this;
}
- /**
- * Load the settings from the given properties
- */
- public void loadFromProperties(Properties properties) {
+ @Override
+ 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;
}
/**
@@ -2790,9 +2047,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 +2269,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 +2278,106 @@ public class DatabaseConfig {
return persistBatchOnCascade;
}
- /**
- * Return the Jackson ObjectMapper.
- * &x64;javax.validation.contstraints.NotNull or
- * &x64;jakarta.validation.contstraints.NotNull
- * with respect to generating a NOT NULL column.
- * false and the javax NotNull annotation is effectively ignored (and
- * we instead use Ebean's own NotNull annotation or JPA Column(nullable=false) annotation.
- */
- public void setUseValidationNotNull(boolean useValidationNotNull) {
+ @Override
+ public DatabaseConfig setUseValidationNotNull(boolean useValidationNotNull) {
this.useValidationNotNull = useValidationNotNull;
+ return this;
}
- /**
- * 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.
- * @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.
- */
- public void setIdGeneratorAutomatic(boolean idGeneratorAutomatic) {
+ @Override
+ public DatabaseConfig setIdGeneratorAutomatic(boolean idGeneratorAutomatic) {
this.idGeneratorAutomatic = idGeneratorAutomatic;
+ return this;
}
- /**
- * Return true if query plan capture is enabled.
- */
+ @Override
public boolean isQueryPlanEnable() {
return queryPlanEnable;
}
- /**
- * Set to true to enable query plan capture.
- */
- public void setQueryPlanEnable(boolean queryPlanEnable) {
+ @Override
+ public DatabaseConfig setQueryPlanEnable(boolean queryPlanEnable) {
this.queryPlanEnable = queryPlanEnable;
+ return this;
}
- /**
- * Return the query plan collection threshold in microseconds.
- */
+ @Override
public long getQueryPlanThresholdMicros() {
return queryPlanThresholdMicros;
}
- /**
- * Set the query plan collection threshold in microseconds.
- *