Used to programmatically construct an Database and optionally register it with the DB singleton.
If you just use DB thout this programmatic configuration Ebean will read the application.properties file and take the configuration from there. This usually includes searching the class path and automatically registering any entity classes and listeners etc.
DatabaseConfig config = new DatabaseConfig();
// read the ebean.properties and load
// those settings into this DatabaseConfig object
config.loadFromProperties();
// explicitly register the entity beans to avoid classpath scanning
config.addClass(Customer.class);
config.addClass(User.class);
Database db = DatabaseFactory.create(config);
Note that DatabaseConfigProvider provides a standard Java ServiceLoader mechanism that can be used to apply configuration to the DatabaseConfig.
- Author:
- emcgreal, rbygrave
- See Also:
-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionConstruct a Database Configuration for programmatically creating an Database. -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(IdGenerator idGenerator) Register a customer IdGenerator instance.void
add
(BeanPersistController beanPersistController) Register a BeanPersistController instance.void
add
(BeanPersistListener beanPersistListener) Register a BeanPersistListener instance.void
add
(BeanPostConstructListener listener) Register a BeanPostConstructListener instance.void
add
(BeanPostLoad postLoad) Register a BeanPostLoad instance.void
add
(BeanQueryAdapter beanQueryAdapter) Register a BeanQueryAdapter instance.void
add
(BulkTableEventListener bulkTableEventListener) Add a BulkTableEventListenervoid
Register all the classes (typically entity classes).void
Programmatically add classes (typically entities) that this server should use.void
addCustomMapping
(DbType type, String columnDefinition) Add a custom type mapping that applies to all platforms.void
addCustomMapping
(DbType type, String columnDefinition, io.ebean.annotation.Platform platform) Add a custom type mapping.void
addMappingLocation
(String mappingLocation) Add a mapping location to search for xml mapping via class path search.void
addPackage
(String packageName) Add a package to search for entities via class path search.void
addServerConfigStartup
(ServerConfigStartup configStartupListener) Add a ServerConfigStartup.io.ebean.annotation.PersistBatch
Return the PersistBatch mode to use for 'batchOnCascade' taking into account if the database platform supports getGeneratedKeys in batch mode.Return the database column used to support history and 'As of' queries.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.Return the configuration for AutoTune.int
Return the Background executor schedule pool size.int
Return the Background executor shutdown seconds.Return the background executor wrapper.Return the list of BulkTableEventListener instances.int
Return the L2 cache default max idle time in seconds.int
Return the L2 cache default max size.int
Return the L2 cache default max time to live in seconds.Return the ChangeLogListener which actually performs the logging of change sets in the background.Return the ChangeLogPrepare.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.Return the classes registered for this database.Return the ClassLoadConfig which is used to detect Joda, Java8 types etc and also create new instances of plugins given a className.getClock()
Get the clock used for setting the timestamps (e.g.Return the constraint naming convention used in DDL generation.Return the container / clustering configuration.Return the current tenant provider.Return the CurrentUserProvider.Return a value used to represent FALSE in the database.Return a value used to represent TRUE in the database.Return the database platform to use for this database.Return the database platform name (can be null).int
Return the number of DB sequence values that should be preallocated.Return the DataSource.io.ebean.datasource.DataSourceConfig
Return the configuration to build a DataSource using Ebean's own DataSource implementation.Return the time zone to use when reading/writing Timestamps via JDBC.Return the DbEncrypt used to encrypt and decrypt properties.Return the DB schema to use.Return the header to use with DDL generation.Return a SQL script to execute before the "create all" DDL has been run.Return a map of placeholder values that are substituted in DDL scripts.Return a comma and equals delimited placeholders that are substituted in DDL scripts.Return SQL script to execute after the "create all" DDL has been run.javax.persistence.EnumType
Return the configuration for the ElasticSearch integration.Return the options for dumping metrics.Return the enabled L2 cache regions.Return the EncryptDeployManager.Return the EncryptKeyManager.Return the Encryptor used to encrypt data on the java client side (as opposed to DB encryption functions).Return the external transaction manager.Return the list of BeanFindController instances.int
Return the Geometry SRID.Return the history table suffix (defaults to _history).Return the custom IdGenerator instances.Return the preferred DB platform IdType.int
Return the default JDBC fetchSize hint for findEach/findEachWhile queries.int
Return the default JDBC fetchSize hint for findList queries.Return the mode to use for Joda LocalTime support 'normal' or 'utc'.Return the JSON format used for Date types.Return the JSON format used for DateTime types.com.fasterxml.jackson.core.JsonFactory
Return the Jackson JsonFactory to use.Return the JSON include mode used when writing JSON.io.ebean.annotation.MutationDetection
Return the default MutableDetection to use with@DbJson
using Jackson.int
Return the default batch size for lazy loading of beans and collections.Return mapping locations to search for xml mapping via class path search.int
Return the max call stack to use for origin location.getName()
Return the name of the Database.Return the NamingConvention.Return the Jackson ObjectMapper.Return packages to search for entities via class path search.io.ebean.annotation.PersistBatch
Return the PersistBatch mode to use by default at the transaction level.io.ebean.annotation.PersistBatch
Return the JDBC batch mode to use per save(), delete(), insert() or update() request.int
Return the batch size used for JDBC batching.Return the BeanPersistController instances.Return the default PersistenceContextScope to be used if one is not explicitly set on a query.Return the BeanPersistListener instances.Return the configuration for DB types (such as UUID and custom mappings).Return the list of BeanPostLoader instances.Return the list of BeanPostLoader instances.Return the configuration for profiling.Return the properties that we used for configuration and were set via a call to loadFromProperties().Return the BeanQueryAdapter instances.int
Gets the query batch size.int
Return the L2 query cache default max idle time in seconds.int
Return the L2 query cache default max size.int
Return the L2 query cache default max time to live in seconds.int
Return the max number of query plans captured per request.long
Return the time after which a capture query plans request will stop capturing more query plans.long
Return the frequency to capture query plans.Return the listener used to process captured query plans.long
Return the query plan collection threshold in microseconds.int
Return the time to live for ebean's internal query plan.Return the ReadAuditLogger to use.Return the ReadAuditPrepare to use.Return the read only DataSource.io.ebean.datasource.DataSourceConfig
Return the configuration for the read only DataSource.Returns the resource directory.Return the ServerCachePlugin.Return the list of ServerConfigStartup instances.<P> P
getServiceObject
(Class<P> cls) Used by plugins to obtain service objects.getServiceObject
(String key) Return the service object given the key.Return the slow query event listener.long
Return the slow query time in millis.Return the tenancy catalog provider.Return the tenancy datasource provider.Return the tenancy mode used.Return the column name used for TenantMode.PARTITION.Return the tenancy schema provider.Returns the V1-UUID-NodeIdReturn the UUID state file.Returns the UUID version mode.boolean
Return true if all DB column and table names should use quoted identifiers.boolean
Return true if entity classes should be loaded and registered via ModuleInfoLoader.boolean
Return true if dirty beans are automatically persisted.boolean
Return true if Ebean should create a DataSource for use with implicit read only transactions.boolean
Return true (default) if the changelog should be written async.boolean
Return true if inserts should be included in the change log by default.boolean
Return true if the Database instance should be created in offline mode.boolean
Return true if the "drop all ddl" should be skipped.boolean
Return true, if extra-ddl.xml should be executed.boolean
Return true if the DDL should be generated.boolean
isDdlRun()
Return true if the DDL should be run.boolean
Return true if strict mode is used which includes a check that non-null columns have a default value.boolean
Returns the default orderById setting for queries.boolean
Return true if this server should be registered as the "default" server with the Ebean singleton.boolean
Return true if the class path search should be disabled.boolean
Return true if L2 cache is disabled.boolean
Return true if lazy loading is disabled on queries by default.boolean
Return true if this Database is a Document store only instance (has no JDBC DB).boolean
Return true if metrics should be dumped when the server is shutdown.boolean
Return true if Duration should be persisted with nanos precision (SQL DECIMAL).boolean
Return true if LOB's should default to fetch eager.boolean
Return true if eq("someProperty", null) should to generate "1=1" rather than "is null" sql expression.boolean
Return true if native ILIKE expression should be used if supported by the database platform (e.g.boolean
When false we need explicit@GeneratedValue
mapping to assign Identity or Sequence generated values.boolean
Return true to use local only L2 cache.boolean
Return true if LocalTime should be persisted with nanos precision.boolean
Return true if L2 cache notification should run in the foreground.boolean
Return true if periodic capture of query plans is enabled.boolean
Return true if query plan capture is enabled.boolean
Return true if this server should be registered with the Ebean singleton when it is created.boolean
Return true if the DB migration should run on server start.boolean
Return true if L2 bean cache should be skipped once writes have occurred on a transaction.boolean
Return true if transactions should rollback on checked exceptions.boolean
Returns true if updates in JDBC batch default to include all properties by default.boolean
Return true if we are running in a JTA Transaction manager.boolean
Returns if we use javax.validation.constraints.NotNullprotected void
This is broken out to allow overridden behaviour.protected void
loads the data source settings to preserve existing behaviour.protected void
This is broken out to allow overridden behaviour.void
Load settings from application.properties, application.yaml and other sources.void
loadFromProperties
(Properties properties) Load the settings from the given propertiesprotected void
Load the configuration settings from the properties file.newPlatformConfig
(String propertiesPath, String platformPrefix) Create a new PlatformConfig based of the one held but with overridden properties by reading properties with the given path and prefix.void
putServiceObject
(Object configObject) Put a service object into configuration such that it can be passed to a plugin.void
putServiceObject
(String key, Object configObject) Put a service object into configuration such that it can be passed to a plugin.void
setAllQuotedIdentifiers
(boolean allQuotedIdentifiers) Set to true if all DB column and table names should use quoted identifiers.void
setAsOfSysPeriod
(String asOfSysPeriod) Set the database column used to support history and 'As of' queries.void
setAsOfViewSuffix
(String 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.void
setAutoPersistUpdates
(boolean autoPersistUpdates) Set to true if dirty beans are automatically persisted.void
setAutoReadOnlyDataSource
(boolean autoReadOnlyDataSource) Set to true if Ebean should create a DataSource for use with implicit read only transactions.void
setAutoTuneConfig
(AutoTuneConfig autoTuneConfig) Set the configuration for AutoTune.void
setBackgroundExecutorSchedulePoolSize
(int backgroundExecutorSchedulePoolSize) Set the Background executor schedule pool size.void
setBackgroundExecutorShutdownSecs
(int backgroundExecutorShutdownSecs) Set the Background executor shutdown seconds.void
setBackgroundExecutorWrapper
(BackgroundExecutorWrapper backgroundExecutorWrapper) Sets the background executor wrapper.void
setCacheMaxIdleTime
(int cacheMaxIdleTime) Set the L2 cache default max idle time in seconds.void
setCacheMaxSize
(int cacheMaxSize) Set the L2 cache default max size.void
setCacheMaxTimeToLive
(int cacheMaxTimeToLive) Set the L2 cache default max time to live in seconds.void
setChangeLogAsync
(boolean changeLogAsync) Sets if the changelog should be written async (default = true).void
setChangeLogIncludeInserts
(boolean changeLogIncludeInserts) Set if inserts should be included in the change log by default.void
setChangeLogListener
(ChangeLogListener changeLogListener) Set the ChangeLogListener which actually performs the logging of change sets in the background.void
setChangeLogPrepare
(ChangeLogPrepare changeLogPrepare) Set the ChangeLogPrepare.void
setChangeLogRegister
(ChangeLogRegister 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.void
setClasses
(List<Class<?>> classes) Set the list of classes (entities, listeners, scalarTypes etc) that should be used for this database.void
setClassLoadConfig
(ClassLoadConfig classLoadConfig) Set the ClassLoadConfig which is used to detect Joda, Java8 types etc and also create new instances of plugins given a className.void
Set the clock used for setting the timestamps (e.g.void
setConstraintNaming
(DbConstraintNaming constraintNaming) Set the constraint naming convention used in DDL generation.void
setContainerConfig
(ContainerConfig containerConfig) Set the container / clustering configuration.void
setCurrentTenantProvider
(CurrentTenantProvider currentTenantProvider) Set the current tenant provider.void
setCurrentUserProvider
(CurrentUserProvider currentUserProvider) Set the CurrentUserProvider.void
setDatabaseBooleanFalse
(String databaseFalse) Set the value to represent FALSE in the database.void
setDatabaseBooleanTrue
(String databaseTrue) Set the value to represent TRUE in the database.void
setDatabasePlatform
(DatabasePlatform databasePlatform) Explicitly set the database platform to use.void
setDatabasePlatformName
(String databasePlatformName) Explicitly set the database platform namevoid
setDatabaseSequenceBatch
(int databaseSequenceBatchSize) Set the number of DB sequence values that should be preallocated and cached by Ebean.void
setDatabaseSequenceBatchSize
(int databaseSequenceBatchSize) Set the number of sequences to fetch/preallocate when using DB sequences.void
setDataSource
(DataSource dataSource) Set a DataSource.void
setDataSourceConfig
(io.ebean.datasource.DataSourceConfig dataSourceConfig) Set the configuration required to build a DataSource using Ebean's own DataSource implementation.void
setDataTimeZone
(String dataTimeZone) Set the time zone to use when reading/writing Timestamps via JDBC.void
setDbEncrypt
(DbEncrypt dbEncrypt) Set the DbEncrypt used to encrypt and decrypt properties.void
setDbOffline
(boolean dbOffline) Set to true if the Database instance should be created in offline mode.void
setDbSchema
(String dbSchema) Set the DB schema to use.void
setDbUuid
(PlatformConfig.DbUuid dbUuid) Set the DB type used to store UUID.void
setDdlCreateOnly
(boolean ddlCreateOnly) Set to true if the "drop all ddl" should be skipped.void
setDdlExtra
(boolean ddlExtra) Set to false if you not want to run the extra-ddl.xml scripts.void
setDdlGenerate
(boolean ddlGenerate) Set to true to generate the "create all" DDL on startup.void
setDdlHeader
(String ddlHeader) Set the header to use with DDL generation.void
setDdlInitSql
(String ddlInitSql) Set a SQL script to execute before the "create all" DDL has been run.void
setDdlPlaceholderMap
(Map<String, String> ddlPlaceholderMap) Set a map of placeholder values that are substituted in DDL scripts.void
setDdlPlaceholders
(String ddlPlaceholders) Set a comma and equals delimited placeholders that are substituted in DDL scripts.void
setDdlRun
(boolean ddlRun) Set to true to run the generated "create all DDL" on startup.void
setDdlSeedSql
(String ddlSeedSql) Set a SQL script to execute after the "create all" DDL has been run.void
setDdlStrictMode
(boolean ddlStrictMode) Set to false to turn off strict mode allowing non-null columns to not have a default value.void
setDefaultEnumType
(javax.persistence.EnumType defaultEnumType) void
setDefaultOrderById
(boolean defaultOrderById) Deprecated.void
setDefaultServer
(boolean defaultServer) Set false if you do not want this Database to be registered as the "default" database with the DB singleton.void
setDisableClasspathSearch
(boolean disableClasspathSearch) Set to true to disable the class path search even for the case where no entity bean classes have been registered.void
setDisableL2Cache
(boolean disableL2Cache) Set to true to disable L2 caching.void
setDisableLazyLoading
(boolean disableLazyLoading) Set to true to disable lazy loading by default.void
setDocStoreConfig
(DocStoreConfig docStoreConfig) Set the configuration for the ElasticSearch integration.void
setDocStoreOnly
(boolean docStoreOnly) Set to true if this Database is Document store only instance (has no JDBC DB).void
setDumpMetricsOnShutdown
(boolean dumpMetricsOnShutdown) Set to true if metrics should be dumped when the server is shutdown.void
setDumpMetricsOptions
(String dumpMetricsOptions) Include 'sql' or 'hash' in options such that they are included in the output.void
setDurationWithNanos
(boolean durationWithNanos) Set to true if Duration should be persisted with nanos precision (SQL DECIMAL).void
setEagerFetchLobs
(boolean eagerFetchLobs) Set to true if you want LOB's to be fetch eager by default.void
setEnabledL2Regions
(String enabledL2Regions) Set the enabled L2 cache regions (comma delimited).void
setEncryptDeployManager
(EncryptDeployManager encryptDeployManager) Set the EncryptDeployManager.void
setEncryptKeyManager
(EncryptKeyManager encryptKeyManager) Set the EncryptKeyManager.void
setEncryptor
(Encryptor encryptor) Set the Encryptor used to encrypt data on the java client side (as opposed to DB encryption functions).void
setExpressionEqualsWithNullAsNoop
(boolean expressionEqualsWithNullAsNoop) Set to true if you want eq("someProperty", null) to generate "1=1" rather than "is null" sql expression.void
setExpressionNativeIlike
(boolean expressionNativeIlike) Set to true to use native ILIKE expression if supported by the database platform (e.g.void
setExternalTransactionManager
(ExternalTransactionManager externalTransactionManager) Set the external transaction manager.void
setFindControllers
(List<BeanFindController> findControllers) Set the list of BeanFindController instances.void
setGeometrySRID
(int geometrySRID) Set the Geometry SRID.void
setHistoryTableSuffix
(String historyTableSuffix) Set the history table suffix.void
setIdGeneratorAutomatic
(boolean idGeneratorAutomatic) Set to false such that Id properties require explicit@GeneratedValue
mapping before they are assigned Identity or Sequence generation based on platform.void
setIdGenerators
(List<IdGenerator> idGenerators) Set the custom IdGenerator instances.void
Set the preferred DB platform IdType.void
setJdbcFetchSizeFindEach
(int jdbcFetchSizeFindEach) Set the default JDBC fetchSize hint for findEach/findEachWhile queries.void
setJdbcFetchSizeFindList
(int jdbcFetchSizeFindList) Set the default JDBC fetchSize hint for findList queries.void
setJodaLocalTimeMode
(String jodaLocalTimeMode) Set the mode to use for Joda LocalTime support 'normal' or 'utc'.void
setJsonDate
(JsonConfig.Date jsonDate) Set the JSON format to use for Date types.void
setJsonDateTime
(JsonConfig.DateTime jsonDateTime) Set the JSON format to use for DateTime types.void
setJsonFactory
(com.fasterxml.jackson.core.JsonFactory jsonFactory) Set the Jackson JsonFactory to use.void
setJsonInclude
(JsonConfig.Include jsonInclude) Set the JSON include mode used when writing JSON.void
setJsonMutationDetection
(io.ebean.annotation.MutationDetection jsonMutationDetection) Set the default MutableDetection to use with@DbJson
using Jackson.void
setLazyLoadBatchSize
(int lazyLoadBatchSize) Set the default batch size for lazy loading.void
setLoadModuleInfo
(boolean loadModuleInfo) Set false to turn off automatic registration of entity beans.void
setLocalOnlyL2Cache
(boolean localOnlyL2Cache) Force the use of local only L2 cache.void
setLocalTimeWithNanos
(boolean localTimeWithNanos) Set to true if LocalTime should be persisted with nanos precision.void
setMappingLocations
(List<String> mappingLocations) Set mapping locations to search for xml mapping via class path search.void
setMaxCallStack
(int maxCallStack) Set the max call stack to use for origin location.void
Set the name of the Database.void
setNamingConvention
(NamingConvention namingConvention) Set the NamingConvention.void
setNotifyL2CacheInForeground
(boolean notifyL2CacheInForeground) Set this to true to run L2 cache notification in the foreground.void
setObjectMapper
(Object objectMapper) Set the Jackson ObjectMapper.void
setPackages
(List<String> packages) Set packages to search for entities via class path search.void
setPersistBatch
(io.ebean.annotation.PersistBatch persistBatch) Set the JDBC batch mode to use at the transaction level.void
setPersistBatching
(boolean persistBatching) Deprecated, please migrate to using setPersistBatch().void
setPersistBatchOnCascade
(io.ebean.annotation.PersistBatch persistBatchOnCascade) Set the JDBC batch mode to use per save(), delete(), insert() or update() request.void
setPersistBatchSize
(int persistBatchSize) Set the batch size used for JDBC batching.void
setPersistControllers
(List<BeanPersistController> persistControllers) Register all the BeanPersistController instances.void
setPersistenceContextScope
(PersistenceContextScope persistenceContextScope) Set the PersistenceContext scope to be used if one is not explicitly set on a query.void
setPersistListeners
(List<BeanPersistListener> persistListeners) Register all the BeanPersistListener instances.void
setPlatformConfig
(PlatformConfig platformConfig) Set the configuration for DB platform (such as UUID and custom mappings).void
setPostConstructListeners
(List<BeanPostConstructListener> listeners) Set the list of BeanPostLoader instances.void
setPostLoaders
(List<BeanPostLoad> postLoaders) Set the list of BeanPostLoader instances.void
setProfilingConfig
(ProfilingConfig profilingConfig) Set the configuration for profiling.void
setQueryAdapters
(List<BeanQueryAdapter> queryAdapters) Register all the BeanQueryAdapter instances.void
setQueryBatchSize
(int queryBatchSize) Sets the query batch size.void
setQueryCacheMaxIdleTime
(int queryCacheMaxIdleTime) Set the L2 query cache default max idle time in seconds.void
setQueryCacheMaxSize
(int queryCacheMaxSize) Set the L2 query cache default max size.void
setQueryCacheMaxTimeToLive
(int queryCacheMaxTimeToLive) Set the L2 query cache default max time to live in seconds.void
setQueryPlanCapture
(boolean queryPlanCapture) Set to true to turn on periodic capture of query plans.void
setQueryPlanCaptureMaxCount
(int queryPlanCaptureMaxCount) Set the max number of query plans captured per request.void
setQueryPlanCaptureMaxTimeMillis
(long queryPlanCaptureMaxTimeMillis) Set the time after which a capture query plans request will stop capturing more query plans.void
setQueryPlanCapturePeriodSecs
(long queryPlanCapturePeriodSecs) Set the frequency in seconds to capture query plans.void
setQueryPlanEnable
(boolean queryPlanEnable) Set to true to enable query plan capture.void
setQueryPlanListener
(QueryPlanListener queryPlanListener) Set the listener used to process captured query plans.void
setQueryPlanThresholdMicros
(long queryPlanThresholdMicros) Set the query plan collection threshold in microseconds.void
setQueryPlanTTLSeconds
(int queryPlanTTLSeconds) Set the time to live for ebean's internal query plan.void
setReadAuditLogger
(ReadAuditLogger readAuditLogger) Set the ReadAuditLogger to use.void
setReadAuditPrepare
(ReadAuditPrepare readAuditPrepare) Set the ReadAuditPrepare to use.void
setReadOnlyDataSource
(DataSource readOnlyDataSource) Set the read only DataSource.void
setReadOnlyDataSourceConfig
(io.ebean.datasource.DataSourceConfig readOnlyDataSourceConfig) Set the configuration for the read only DataSource.void
setRegister
(boolean register) Set to false if you do not want this server to be registered with the Ebean singleton when it is created.void
setResourceDirectory
(String resourceDirectory) Sets the resource directory.void
setRunMigration
(boolean runMigration) Set to true to run DB migrations on server start.void
setServerCachePlugin
(ServerCachePlugin serverCachePlugin) Set the ServerCachePlugin to use.void
setSkipCacheAfterWrite
(boolean skipCacheAfterWrite) Set to false when we still want to hit the cache after a write has occurred on a transaction.void
setSkipDataSourceCheck
(boolean skipDataSourceCheck) Set to true to skip the startup DataSource check.void
setSlowQueryListener
(SlowQueryListener slowQueryListener) Set the slow query event listener.void
setSlowQueryMillis
(long slowQueryMillis) Set the slow query time in millis.void
setTenantCatalogProvider
(TenantCatalogProvider tenantCatalogProvider) Set the tenancy catalog provider.void
setTenantDataSourceProvider
(TenantDataSourceProvider tenantDataSourceProvider) Set the tenancy datasource provider.void
setTenantMode
(TenantMode tenantMode) Set the tenancy mode to use.void
setTenantPartitionColumn
(String tenantPartitionColumn) Set the column name used for TenantMode.PARTITION.void
setTenantSchemaProvider
(TenantSchemaProvider tenantSchemaProvider) Set the tenancy schema provider.void
setTransactionRollbackOnChecked
(boolean transactionRollbackOnChecked) Set to true if transactions should by default rollback on checked exceptions.void
setUpdateAllPropertiesInBatch
(boolean updateAllPropertiesInBatch) Set to false if by default updates in JDBC batch should not include all properties.void
setUseJtaTransactionManager
(boolean useJtaTransactionManager) Set to true if we are running in a JTA Transaction manager.void
setUseValidationNotNull
(boolean useValidationNotNull) Controls if Ebean should ignore&x64;javax.validation.contstraints.NotNull
or&x64;jakarta.validation.contstraints.NotNull
with respect to generating aNOT NULL
column.void
setUuidNodeId
(String uuidNodeId) Sets the V1-UUID-NodeId.void
setUuidStateFile
(String uuidStateFile) Set the UUID state file.void
setUuidVersion
(DatabaseConfig.UuidVersion uuidVersion) Sets the UUID version mode.boolean
Return true if the startup DataSource check should be skipped.
-
Constructor Details
-
DatabaseConfig
public DatabaseConfig()Construct a Database Configuration for programmatically creating an Database.
-
-
Method Details
-
getClock
Get the clock used for setting the timestamps (e.g. @UpdatedTimestamp) on objects. -
setClock
Set the clock used for setting the timestamps (e.g. @UpdatedTimestamp) on objects. -
getSlowQueryMillis
public long getSlowQueryMillis()Return the slow query time in millis. -
setSlowQueryMillis
public void setSlowQueryMillis(long slowQueryMillis) Set the slow query time in millis. -
getSlowQueryListener
Return the slow query event listener. -
setSlowQueryListener
Set the slow query event listener. -
setDefaultOrderById
Deprecated.Deprecated - look to have explicit order by. Sets the default orderById setting for queries. -
isDefaultOrderById
public boolean isDefaultOrderById()Returns the default orderById setting for queries. -
putServiceObject
Put a service object into configuration such that it can be passed to a plugin.For example, put IgniteConfiguration in to be passed to the Ignite plugin.
-
getServiceObject
Return the service object given the key. -
putServiceObject
Put a service object into configuration such that it can be passed to a plugin.JedisPool jedisPool = .. config.putServiceObject(jedisPool);
-
getServiceObject
Used by plugins to obtain service objects.JedisPool jedisPool = config.getServiceObject(JedisPool.class);
- Parameters:
cls
- The type of the service object to obtain- Returns:
- The service object given the class type
-
getJsonFactory
public com.fasterxml.jackson.core.JsonFactory getJsonFactory()Return the Jackson JsonFactory to use.If not set a default implementation will be used.
-
setJsonFactory
public void setJsonFactory(com.fasterxml.jackson.core.JsonFactory jsonFactory) Set the Jackson JsonFactory to use.If not set a default implementation will be used.
-
getJsonDateTime
Return the JSON format used for DateTime types. -
setJsonDateTime
Set the JSON format to use for DateTime types. -
getJsonDate
Return the JSON format used for Date types. -
setJsonDate
Set the JSON format to use for Date types. -
getJsonInclude
Return the JSON include mode used when writing JSON. -
setJsonInclude
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.
-
getJsonMutationDetection
public io.ebean.annotation.MutationDetection getJsonMutationDetection()Return the default MutableDetection to use with@DbJson
using Jackson.- See Also:
-
DbJson.mutationDetection()
-
setJsonMutationDetection
public void setJsonMutationDetection(io.ebean.annotation.MutationDetection jsonMutationDetection) Set the default MutableDetection to use with@DbJson
using Jackson.- See Also:
-
DbJson.mutationDetection()
-
getName
Return the name of the Database. -
setName
Set the name of the Database. -
getContainerConfig
Return the container / clustering configuration. The container holds all the Database instances and provides clustering communication services to all the Database instances. -
setContainerConfig
Set the container / clustering configuration. The container holds all the Database instances and provides clustering communication services to all the Database instances. -
isRegister
public boolean isRegister()Return true if this server should be registered with the Ebean singleton when it is created.By default this is set to true.
-
setRegister
public void setRegister(boolean 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.
-
isDefaultServer
public boolean isDefaultServer()Return true if this server should be registered as the "default" server with the Ebean singleton.This is only used when
setRegister(boolean)
is also true. -
setDefaultServer
public void setDefaultServer(boolean 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
setRegister(boolean)
is also true. -
getCurrentUserProvider
Return the CurrentUserProvider. This is used to populate @WhoCreated, @WhoModified and support other audit features (who executed a query etc). -
setCurrentUserProvider
Set the CurrentUserProvider. This is used to populate @WhoCreated, @WhoModified and support other audit features (who executed a query etc). -
getTenantMode
Return the tenancy mode used. -
setTenantMode
Set the tenancy mode to use. -
getTenantPartitionColumn
Return the column name used for TenantMode.PARTITION. -
setTenantPartitionColumn
Set the column name used for TenantMode.PARTITION. -
getCurrentTenantProvider
Return the current tenant provider. -
setCurrentTenantProvider
Set the current tenant provider. -
getTenantDataSourceProvider
Return the tenancy datasource provider. -
setTenantDataSourceProvider
Set the tenancy datasource provider. -
getTenantSchemaProvider
Return the tenancy schema provider. -
setTenantSchemaProvider
Set the tenancy schema provider. -
getTenantCatalogProvider
Return the tenancy catalog provider. -
setTenantCatalogProvider
Set the tenancy catalog provider. -
isAutoPersistUpdates
public boolean isAutoPersistUpdates()Return true if dirty beans are automatically persisted. -
setAutoPersistUpdates
public void setAutoPersistUpdates(boolean autoPersistUpdates) Set to true if dirty beans are automatically persisted. -
getPersistBatch
public io.ebean.annotation.PersistBatch getPersistBatch()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.
-
setPersistBatch
public void setPersistBatch(io.ebean.annotation.PersistBatch 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.
-
getPersistBatchOnCascade
public io.ebean.annotation.PersistBatch getPersistBatchOnCascade()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.
-
setPersistBatchOnCascade
public void setPersistBatchOnCascade(io.ebean.annotation.PersistBatch 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.
-
setPersistBatching
public void setPersistBatching(boolean persistBatching) 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
setPersistBatch(PersistBatch.ALL)
or when false tosetPersistBatch(PersistBatch.NONE)
-
getPersistBatchSize
public int getPersistBatchSize()Return the batch size used for JDBC batching. This defaults to 20. -
setPersistBatchSize
public void setPersistBatchSize(int 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 Also:
-
getQueryBatchSize
public int getQueryBatchSize()Gets the query batch size. This defaults to 100.- Returns:
- the query batch size
-
setQueryBatchSize
public void setQueryBatchSize(int queryBatchSize) Sets the query batch size. This defaults to 100.- Parameters:
queryBatchSize
- the new query batch size
-
getDefaultEnumType
public javax.persistence.EnumType getDefaultEnumType() -
setDefaultEnumType
public void setDefaultEnumType(javax.persistence.EnumType defaultEnumType) -
isDisableLazyLoading
public boolean isDisableLazyLoading()Return true if lazy loading is disabled on queries by default. -
setDisableLazyLoading
public void setDisableLazyLoading(boolean disableLazyLoading) Set to true to disable lazy loading by default.It can be turned on per query via
Query.setDisableLazyLoading(boolean)
. -
getLazyLoadBatchSize
public int getLazyLoadBatchSize()Return the default batch size for lazy loading of beans and collections. -
setLazyLoadBatchSize
public void setLazyLoadBatchSize(int 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.
-
setDatabaseSequenceBatchSize
public void setDatabaseSequenceBatchSize(int databaseSequenceBatchSize) 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).
-
getJdbcFetchSizeFindList
public int getJdbcFetchSizeFindList()Return the default JDBC fetchSize hint for findList queries. -
setJdbcFetchSizeFindList
public void setJdbcFetchSizeFindList(int jdbcFetchSizeFindList) Set the default JDBC fetchSize hint for findList queries. -
getJdbcFetchSizeFindEach
public int getJdbcFetchSizeFindEach()Return the default JDBC fetchSize hint for findEach/findEachWhile queries. -
setJdbcFetchSizeFindEach
public void setJdbcFetchSizeFindEach(int jdbcFetchSizeFindEach) Set the default JDBC fetchSize hint for findEach/findEachWhile queries. -
getChangeLogPrepare
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.
-
setChangeLogPrepare
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.
-
getChangeLogListener
Return the ChangeLogListener which actually performs the logging of change sets in the background. -
setChangeLogListener
Set the ChangeLogListener which actually performs the logging of change sets in the background. -
getChangeLogRegister
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. -
setChangeLogRegister
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. -
isChangeLogIncludeInserts
public boolean isChangeLogIncludeInserts()Return true if inserts should be included in the change log by default. -
setChangeLogIncludeInserts
public void setChangeLogIncludeInserts(boolean changeLogIncludeInserts) Set if inserts should be included in the change log by default. -
isChangeLogAsync
public boolean isChangeLogAsync()Return true (default) if the changelog should be written async. -
setChangeLogAsync
public void setChangeLogAsync(boolean changeLogAsync) Sets if the changelog should be written async (default = true). -
getReadAuditLogger
Return the ReadAuditLogger to use. -
setReadAuditLogger
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). -
getReadAuditPrepare
Return the ReadAuditPrepare to use. -
setReadAuditPrepare
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.
-
getProfilingConfig
Return the configuration for profiling. -
setProfilingConfig
Set the configuration for profiling. -
getDbSchema
Return the DB schema to use. -
setDbSchema
Set the DB schema to use. This specifies to use this schema for:- Running Database migrations - Create and use the DB schema
- Testing DDL - Create-all.sql DDL execution creates and uses schema
- Testing Docker - Set default schema on connection URL
-
getGeometrySRID
public int getGeometrySRID()Return the Geometry SRID. -
setGeometrySRID
public void setGeometrySRID(int geometrySRID) Set the Geometry SRID. -
getDataTimeZone
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.
-
setDataTimeZone
Set the time zone to use when reading/writing Timestamps via JDBC. -
getAsOfViewSuffix
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. -
setAsOfViewSuffix
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. -
getAsOfSysPeriod
Return the database column used to support history and 'As of' queries. This column is a timestamp range or equivalent. -
setAsOfSysPeriod
Set the database column used to support history and 'As of' queries. This column is a timestamp range or equivalent. -
getHistoryTableSuffix
Return the history table suffix (defaults to _history). -
setHistoryTableSuffix
Set the history table suffix. -
isUseJtaTransactionManager
public boolean isUseJtaTransactionManager()Return true if we are running in a JTA Transaction manager. -
setUseJtaTransactionManager
public void setUseJtaTransactionManager(boolean useJtaTransactionManager) Set to true if we are running in a JTA Transaction manager. -
getExternalTransactionManager
Return the external transaction manager. -
setExternalTransactionManager
Set the external transaction manager. -
getServerCachePlugin
Return the ServerCachePlugin. -
setServerCachePlugin
Set the ServerCachePlugin to use. -
isEagerFetchLobs
public boolean isEagerFetchLobs()Return true if LOB's should default to fetch eager. By default this is set to false and LOB's must be explicitly fetched. -
setEagerFetchLobs
public void setEagerFetchLobs(boolean 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. -
getMaxCallStack
public int getMaxCallStack()Return the max call stack to use for origin location. -
setMaxCallStack
public void setMaxCallStack(int maxCallStack) Set the max call stack to use for origin location. -
isTransactionRollbackOnChecked
public boolean isTransactionRollbackOnChecked()Return true if transactions should rollback on checked exceptions. -
setTransactionRollbackOnChecked
public void setTransactionRollbackOnChecked(boolean transactionRollbackOnChecked) Set to true if transactions should by default rollback on checked exceptions. -
getBackgroundExecutorSchedulePoolSize
public int getBackgroundExecutorSchedulePoolSize()Return the Background executor schedule pool size. Defaults to 1. -
setBackgroundExecutorSchedulePoolSize
public void setBackgroundExecutorSchedulePoolSize(int backgroundExecutorSchedulePoolSize) Set the Background executor schedule pool size. -
getBackgroundExecutorShutdownSecs
public int getBackgroundExecutorShutdownSecs()Return the Background executor shutdown seconds. This is the time allowed for the pool to shutdown nicely before it is forced shutdown. -
setBackgroundExecutorShutdownSecs
public void setBackgroundExecutorShutdownSecs(int backgroundExecutorShutdownSecs) Set the Background executor shutdown seconds. This is the time allowed for the pool to shutdown nicely before it is forced shutdown. -
getBackgroundExecutorWrapper
Return the background executor wrapper. -
setBackgroundExecutorWrapper
Sets the background executor wrapper. The wrapper is used when a task is sent to background and should copy the thread-locals. -
getCacheMaxSize
public int getCacheMaxSize()Return the L2 cache default max size. -
setCacheMaxSize
public void setCacheMaxSize(int cacheMaxSize) Set the L2 cache default max size. -
getCacheMaxIdleTime
public int getCacheMaxIdleTime()Return the L2 cache default max idle time in seconds. -
setCacheMaxIdleTime
public void setCacheMaxIdleTime(int cacheMaxIdleTime) Set the L2 cache default max idle time in seconds. -
getCacheMaxTimeToLive
public int getCacheMaxTimeToLive()Return the L2 cache default max time to live in seconds. -
setCacheMaxTimeToLive
public void setCacheMaxTimeToLive(int cacheMaxTimeToLive) Set the L2 cache default max time to live in seconds. -
getQueryCacheMaxSize
public int getQueryCacheMaxSize()Return the L2 query cache default max size. -
setQueryCacheMaxSize
public void setQueryCacheMaxSize(int queryCacheMaxSize) Set the L2 query cache default max size. -
getQueryCacheMaxIdleTime
public int getQueryCacheMaxIdleTime()Return the L2 query cache default max idle time in seconds. -
setQueryCacheMaxIdleTime
public void setQueryCacheMaxIdleTime(int queryCacheMaxIdleTime) Set the L2 query cache default max idle time in seconds. -
getQueryCacheMaxTimeToLive
public int getQueryCacheMaxTimeToLive()Return the L2 query cache default max time to live in seconds. -
setQueryCacheMaxTimeToLive
public void setQueryCacheMaxTimeToLive(int queryCacheMaxTimeToLive) Set the L2 query cache default max time to live in seconds. -
getNamingConvention
Return the NamingConvention.If none has been set the default UnderscoreNamingConvention is used.
-
setNamingConvention
Set the NamingConvention.If none is set the default UnderscoreNamingConvention is used.
-
isAllQuotedIdentifiers
public boolean isAllQuotedIdentifiers()Return true if all DB column and table names should use quoted identifiers. -
setAllQuotedIdentifiers
public void setAllQuotedIdentifiers(boolean allQuotedIdentifiers) 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).
-
isDocStoreOnly
public boolean isDocStoreOnly()Return true if this Database is a Document store only instance (has no JDBC DB). -
setDocStoreOnly
public void setDocStoreOnly(boolean docStoreOnly) Set to true if this Database is Document store only instance (has no JDBC DB). -
getDocStoreConfig
Return the configuration for the ElasticSearch integration. -
setDocStoreConfig
Set the configuration for the ElasticSearch integration. -
getConstraintNaming
Return the constraint naming convention used in DDL generation. -
setConstraintNaming
Set the constraint naming convention used in DDL generation. -
getAutoTuneConfig
Return the configuration for AutoTune. -
setAutoTuneConfig
Set the configuration for AutoTune. -
skipDataSourceCheck
public boolean skipDataSourceCheck()Return true if the startup DataSource check should be skipped. -
setSkipDataSourceCheck
public void setSkipDataSourceCheck(boolean skipDataSourceCheck) Set to true to skip the startup DataSource check. -
getDataSource
Return the DataSource. -
setDataSource
Set a DataSource. -
getReadOnlyDataSource
Return the read only DataSource. -
setReadOnlyDataSource
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.
-
getDataSourceConfig
public io.ebean.datasource.DataSourceConfig getDataSourceConfig()Return the configuration to build a DataSource using Ebean's own DataSource implementation. -
setDataSourceConfig
public void setDataSourceConfig(io.ebean.datasource.DataSourceConfig dataSourceConfig) Set the configuration required to build a DataSource using Ebean's own DataSource implementation. -
isAutoReadOnlyDataSource
public boolean isAutoReadOnlyDataSource()Return true if Ebean should create a DataSource for use with implicit read only transactions. -
setAutoReadOnlyDataSource
public void setAutoReadOnlyDataSource(boolean autoReadOnlyDataSource) Set to true if Ebean should create a DataSource for use with implicit read only transactions. -
getReadOnlyDataSourceConfig
public io.ebean.datasource.DataSourceConfig getReadOnlyDataSourceConfig()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.
-
setReadOnlyDataSourceConfig
public void setReadOnlyDataSourceConfig(io.ebean.datasource.DataSourceConfig readOnlyDataSourceConfig) Set the configuration for the read only DataSource. -
getDatabaseBooleanTrue
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").
-
setDatabaseBooleanTrue
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").
-
getDatabaseBooleanFalse
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").
-
setDatabaseBooleanFalse
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").
-
getDatabaseSequenceBatchSize
public int getDatabaseSequenceBatchSize()Return the number of DB sequence values that should be preallocated. -
setDatabaseSequenceBatch
public void setDatabaseSequenceBatch(int databaseSequenceBatchSize) 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.
-
getDatabasePlatformName
Return the database platform name (can be null).If null then the platform is determined automatically via the JDBC driver information.
-
setDatabasePlatformName
Explicitly set the database platform nameIf 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.
-
getDatabasePlatform
Return the database platform to use for this database. -
setDatabasePlatform
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.
-
getIdType
Return the preferred DB platform IdType. -
setIdType
Set the preferred DB platform IdType. -
getEncryptKeyManager
Return the EncryptKeyManager. -
setEncryptKeyManager
Set the EncryptKeyManager.This is required when you want to use encrypted properties.
You can also set this in ebean.proprerties:
# set via ebean.properties ebean.encryptKeyManager=org.avaje.tests.basic.encrypt.BasicEncyptKeyManager
-
getEncryptDeployManager
Return the EncryptDeployManager.This is optionally used to programmatically define which columns are encrypted instead of using the
Encrypted
Annotation. -
setEncryptDeployManager
Set the EncryptDeployManager.This is optionally used to programmatically define which columns are encrypted instead of using the
Encrypted
Annotation. -
getEncryptor
Return the Encryptor used to encrypt data on the java client side (as opposed to DB encryption functions). -
setEncryptor
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.
-
isDbOffline
public boolean isDbOffline()Return true if the Database instance should be created in offline mode. -
setDbOffline
public void setDbOffline(boolean 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.
-
getDbEncrypt
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.
-
setDbEncrypt
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)
-
getPlatformConfig
Return the configuration for DB types (such as UUID and custom mappings). -
setPlatformConfig
Set the configuration for DB platform (such as UUID and custom mappings). -
setDbUuid
Set the DB type used to store UUID. -
getUuidVersion
Returns the UUID version mode. -
setUuidVersion
Sets the UUID version mode. -
getUuidStateFile
Return the UUID state file. -
setUuidStateFile
Set the UUID state file. -
getUuidNodeId
Returns the V1-UUID-NodeId -
setUuidNodeId
Sets the V1-UUID-NodeId. -
isLocalTimeWithNanos
public boolean isLocalTimeWithNanos()Return true if LocalTime should be persisted with nanos precision. -
setLocalTimeWithNanos
public void setLocalTimeWithNanos(boolean localTimeWithNanos) Set to true if LocalTime should be persisted with nanos precision.Otherwise it is persisted using java.sql.Time which is seconds precision.
-
isDurationWithNanos
public boolean isDurationWithNanos()Return true if Duration should be persisted with nanos precision (SQL DECIMAL).Otherwise it is persisted with second precision (SQL INTEGER).
-
setDurationWithNanos
public void setDurationWithNanos(boolean durationWithNanos) Set to true if Duration should be persisted with nanos precision (SQL DECIMAL).Otherwise it is persisted with second precision (SQL INTEGER).
-
setRunMigration
public void setRunMigration(boolean runMigration) 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.
-
isRunMigration
public boolean isRunMigration()Return true if the DB migration should run on server start. -
setDdlGenerate
public void setDdlGenerate(boolean ddlGenerate) 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.
-
setDdlRun
public void setDdlRun(boolean ddlRun) 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.
-
setDdlExtra
public void setDdlExtra(boolean ddlExtra) 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.
-
isDdlCreateOnly
public boolean isDdlCreateOnly()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.
-
setDdlCreateOnly
public void setDdlCreateOnly(boolean 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.
-
getDdlSeedSql
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.
-
setDdlSeedSql
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.
-
getDdlInitSql
Return a SQL script to execute before the "create all" DDL has been run. -
setDdlInitSql
Set a SQL script to execute before the "create all" DDL has been run. -
isDdlGenerate
public boolean isDdlGenerate()Return true if the DDL should be generated. -
isDdlRun
public boolean isDdlRun()Return true if the DDL should be run. -
isDdlExtra
public boolean isDdlExtra()Return true, if extra-ddl.xml should be executed. -
setDdlHeader
Set the header to use with DDL generation. -
getDdlHeader
Return the header to use with DDL generation. -
isDdlStrictMode
public boolean isDdlStrictMode()Return true if strict mode is used which includes a check that non-null columns have a default value. -
setDdlStrictMode
public void setDdlStrictMode(boolean ddlStrictMode) Set to false to turn off strict mode allowing non-null columns to not have a default value. -
getDdlPlaceholders
Return a comma and equals delimited placeholders that are substituted in DDL scripts. -
setDdlPlaceholders
Set a comma and equals delimited placeholders that are substituted in DDL scripts. -
getDdlPlaceholderMap
Return a map of placeholder values that are substituted in DDL scripts. -
setDdlPlaceholderMap
Set a map of placeholder values that are substituted in DDL scripts. -
isDisableClasspathSearch
public boolean isDisableClasspathSearch()Return true if the class path search should be disabled. -
setDisableClasspathSearch
public void setDisableClasspathSearch(boolean disableClasspathSearch) Set to true to disable the class path search even for the case where no entity bean classes have been registered. This can be used to start an Database instance just to use the SQL functions such as SqlQuery, SqlUpdate etc. -
getJodaLocalTimeMode
Return the mode to use for Joda LocalTime support 'normal' or 'utc'. -
setJodaLocalTimeMode
Set the mode to use for Joda LocalTime support 'normal' or 'utc'. -
addClass
Programmatically add classes (typically entities) that this server should use.The class can be an Entity, Embedded type, ScalarType, BeanPersistListener, BeanFinder or BeanPersistController.
If no classes are specified then the classes are found automatically via searching the class path.
Alternatively the classes can be added via
setClasses(List)
.- Parameters:
cls
- the entity type (or other type) that should be registered by this database.
-
addAll
Register all the classes (typically entity classes). -
addPackage
Add a package to search for entities via class path search.This is only used if classes have not been explicitly specified.
-
getPackages
Return packages to search for entities via class path search.This is only used if classes have not been explicitly specified.
-
setPackages
Set packages to search for entities via class path search.This is only used if classes have not been explicitly specified.
-
setClasses
Set the list of classes (entities, listeners, scalarTypes etc) that should be used for this database.If no classes are specified then the classes are found automatically via searching the class path.
Alternatively the classes can contain added via
addClass(Class)
. -
getClasses
Return the classes registered for this database. Typically this includes entities and perhaps listeners. -
isSkipCacheAfterWrite
public boolean isSkipCacheAfterWrite()Return true if L2 bean cache should be skipped once writes have occurred on a transaction.This defaults to true and means that for "find by id" and "find by natural key" queries that normally hit L2 bean cache automatically will not do so after a write/persist on the transaction.
// 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 Also:
-
setSkipCacheAfterWrite
public void setSkipCacheAfterWrite(boolean skipCacheAfterWrite) Set to false when we still want to hit the cache after a write has occurred on a transaction. -
isUpdateAllPropertiesInBatch
public boolean isUpdateAllPropertiesInBatch()Returns true if updates in JDBC batch default to include all properties by default. -
setUpdateAllPropertiesInBatch
public void setUpdateAllPropertiesInBatch(boolean updateAllPropertiesInBatch) Set to false if by default updates in JDBC batch should not include all properties.This mode can be explicitly set per transaction.
-
getResourceDirectory
Returns the resource directory. -
setResourceDirectory
Sets the resource directory. -
addCustomMapping
public void addCustomMapping(DbType type, String columnDefinition, io.ebean.annotation.Platform platform) Add a custom type mapping.// 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);
- Parameters:
type
- The DB type this mapping should apply tocolumnDefinition
- The column definition that should be usedplatform
- Optionally specify the platform this mapping should apply to.
-
addCustomMapping
Add a custom type mapping that applies to all platforms.// 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");
- Parameters:
type
- The DB type this mapping should apply tocolumnDefinition
- The column definition that should be used
-
add
Register a BeanQueryAdapter instance.Note alternatively you can use
setQueryAdapters(List)
to set all the BeanQueryAdapter instances. -
getQueryAdapters
Return the BeanQueryAdapter instances. -
setQueryAdapters
Register all the BeanQueryAdapter instances.Note alternatively you can use
add(BeanQueryAdapter)
to add BeanQueryAdapter instances one at a time. -
getIdGenerators
Return the custom IdGenerator instances. -
setIdGenerators
Set the custom IdGenerator instances. -
add
Register a customer IdGenerator instance. -
add
Register a BeanPersistController instance.Note alternatively you can use
setPersistControllers(List)
to set all the BeanPersistController instances. -
add
Register a BeanPostLoad instance.Note alternatively you can use
setPostLoaders(List)
to set all the BeanPostLoad instances. -
add
Register a BeanPostConstructListener instance.Note alternatively you can use
setPostConstructListeners(List)
to set all the BeanPostConstructListener instances. -
getFindControllers
Return the list of BeanFindController instances. -
setFindControllers
Set the list of BeanFindController instances. -
getPostLoaders
Return the list of BeanPostLoader instances. -
setPostLoaders
Set the list of BeanPostLoader instances. -
getPostConstructListeners
Return the list of BeanPostLoader instances. -
setPostConstructListeners
Set the list of BeanPostLoader instances. -
getPersistControllers
Return the BeanPersistController instances. -
setPersistControllers
Register all the BeanPersistController instances.Note alternatively you can use
add(BeanPersistController)
to add BeanPersistController instances one at a time. -
add
Register a BeanPersistListener instance.Note alternatively you can use
setPersistListeners(List)
to set all the BeanPersistListener instances. -
getPersistListeners
Return the BeanPersistListener instances. -
add
Add a BulkTableEventListener -
getBulkTableEventListeners
Return the list of BulkTableEventListener instances. -
addServerConfigStartup
Add a ServerConfigStartup. -
getServerConfigStartupListeners
Return the list of ServerConfigStartup instances. -
setPersistListeners
Register all the BeanPersistListener instances.Note alternatively you can use
add(BeanPersistListener)
to add BeanPersistListener instances one at a time. -
getPersistenceContextScope
Return the default PersistenceContextScope to be used if one is not explicitly set on a query. The PersistenceContextScope can specified on each query via.Query#setPersistenceContextScope(io.ebean.PersistenceContextScope)
. If it is not set on the query this default scope is used. -
setPersistenceContextScope
Set the PersistenceContext scope to be used if one is not explicitly set on a query. This defaults toPersistenceContextScope.TRANSACTION
. The PersistenceContextScope can specified on each query via.Query#setPersistenceContextScope(io.ebean.PersistenceContextScope)
. If it is not set on the query this scope is used. -
getClassLoadConfig
Return the ClassLoadConfig which is used to detect Joda, Java8 types etc and also create new instances of plugins given a className. -
setClassLoadConfig
Set the ClassLoadConfig which is used to detect Joda, Java8 types etc and also create new instances of plugins given a className. -
loadFromProperties
public void loadFromProperties()Load settings from application.properties, application.yaml and other sources.Uses
avaje-config
to load configuration properties. Goto https://avaje.io/config for detail on how and where properties are loaded from. -
loadFromProperties
Load the settings from the given properties -
getProperties
Return the properties that we used for configuration and were set via a call to loadFromProperties(). -
loadDataSourceSettings
loads the data source settings to preserve existing behaviour. IMHO, if someone has set the datasource config already, they don't want the settings to be reloaded and reset. This allows a descending class to override this behaviour and prevent it from happening.- Parameters:
p
- - The defined property source passed to load settings
-
loadDocStoreSettings
This is broken out to allow overridden behaviour. -
loadAutoTuneSettings
This is broken out to allow overridden behaviour. -
loadSettings
Load the configuration settings from the properties file. -
appliedPersistBatchOnCascade
public io.ebean.annotation.PersistBatch appliedPersistBatchOnCascade()Return the PersistBatch mode to use for 'batchOnCascade' taking into account if the database platform supports getGeneratedKeys in batch mode. -
getObjectMapper
Return the Jackson ObjectMapper.Note that this is not strongly typed as Jackson ObjectMapper is an optional dependency.
-
setObjectMapper
Set the Jackson ObjectMapper.Note that this is not strongly typed as Jackson ObjectMapper is an optional dependency.
-
isExpressionEqualsWithNullAsNoop
public boolean isExpressionEqualsWithNullAsNoop()Return true if eq("someProperty", null) should to generate "1=1" rather than "is null" sql expression. -
setExpressionEqualsWithNullAsNoop
public void setExpressionEqualsWithNullAsNoop(boolean 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".
-
isExpressionNativeIlike
public boolean isExpressionNativeIlike()Return true if native ILIKE expression should be used if supported by the database platform (e.g. Postgres). -
setExpressionNativeIlike
public void setExpressionNativeIlike(boolean expressionNativeIlike) Set to true to use native ILIKE expression if supported by the database platform (e.g. Postgres). -
getEnabledL2Regions
Return the enabled L2 cache regions. -
setEnabledL2Regions
Set the enabled L2 cache regions (comma delimited). -
isDisableL2Cache
public boolean isDisableL2Cache()Return true if L2 cache is disabled. -
setDisableL2Cache
public void setDisableL2Cache(boolean disableL2Cache) Set to true to disable L2 caching. Typically useful in performance testing. -
isLocalOnlyL2Cache
public boolean isLocalOnlyL2Cache()Return true to use local only L2 cache. Effectively ignore l2 cache plugin like ebean-redis etc. -
setLocalOnlyL2Cache
public void setLocalOnlyL2Cache(boolean localOnlyL2Cache) Force the use of local only L2 cache. Effectively ignore l2 cache plugin like ebean-redis etc. -
isUseValidationNotNull
public boolean isUseValidationNotNull()Returns if we use javax.validation.constraints.NotNull -
setUseValidationNotNull
public void setUseValidationNotNull(boolean useValidationNotNull) Controls if Ebean should ignore&x64;javax.validation.contstraints.NotNull
or&x64;jakarta.validation.contstraints.NotNull
with respect to generating aNOT NULL
column.Normally when Ebean sees javax NotNull annotation it means that column is defined as NOT NULL. Set this to
false
and the javax NotNull annotation is effectively ignored (and we instead use Ebean's own NotNull annotation or JPA Column(nullable=false) annotation. -
isNotifyL2CacheInForeground
public boolean isNotifyL2CacheInForeground()Return true if L2 cache notification should run in the foreground. -
setNotifyL2CacheInForeground
public void setNotifyL2CacheInForeground(boolean notifyL2CacheInForeground) Set this to true to run L2 cache notification in the foreground.In general we don't want to do that as when we use a distributed cache (like Ignite, Hazelcast etc) we are making network calls and we prefer to do this in background and not impact the response time of the executing transaction.
-
getQueryPlanTTLSeconds
public int getQueryPlanTTLSeconds()Return the time to live for ebean's internal query plan. -
setQueryPlanTTLSeconds
public void setQueryPlanTTLSeconds(int 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.
-
newPlatformConfig
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.
- Parameters:
propertiesPath
- The properties path used for loading and setting propertiesplatformPrefix
- The prefix used for loading and setting properties- Returns:
- A copy of the PlatformConfig with overridden properties
-
addMappingLocation
Add a mapping location to search for xml mapping via class path search. -
getMappingLocations
Return mapping locations to search for xml mapping via class path search. -
setMappingLocations
Set mapping locations to search for xml mapping via class path search.This is only used if classes have not been explicitly specified.
-
isIdGeneratorAutomatic
public boolean isIdGeneratorAutomatic()When false we need explicit@GeneratedValue
mapping to assign Identity or Sequence generated values. When true Id properties are automatically assigned Identity or Sequence without the GeneratedValue mapping. -
setIdGeneratorAutomatic
public void setIdGeneratorAutomatic(boolean idGeneratorAutomatic) Set to false such that Id properties require explicit@GeneratedValue
mapping before they are assigned Identity or Sequence generation based on platform. -
isQueryPlanEnable
public boolean isQueryPlanEnable()Return true if query plan capture is enabled. -
setQueryPlanEnable
public void setQueryPlanEnable(boolean queryPlanEnable) Set to true to enable query plan capture. -
getQueryPlanThresholdMicros
public long getQueryPlanThresholdMicros()Return the query plan collection threshold in microseconds. -
setQueryPlanThresholdMicros
public void setQueryPlanThresholdMicros(long queryPlanThresholdMicros) Set the query plan collection threshold in microseconds.Queries executing slower than this will have bind values captured such that later the query plan can be captured and reported.
-
isQueryPlanCapture
public boolean isQueryPlanCapture()Return true if periodic capture of query plans is enabled. -
setQueryPlanCapture
public void setQueryPlanCapture(boolean queryPlanCapture) Set to true to turn on periodic capture of query plans. -
getQueryPlanCapturePeriodSecs
public long getQueryPlanCapturePeriodSecs()Return the frequency to capture query plans. -
setQueryPlanCapturePeriodSecs
public void setQueryPlanCapturePeriodSecs(long queryPlanCapturePeriodSecs) Set the frequency in seconds to capture query plans. -
getQueryPlanCaptureMaxTimeMillis
public long getQueryPlanCaptureMaxTimeMillis()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.
-
setQueryPlanCaptureMaxTimeMillis
public void setQueryPlanCaptureMaxTimeMillis(long 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.
-
getQueryPlanCaptureMaxCount
public int getQueryPlanCaptureMaxCount()Return the max number of query plans captured per request. -
setQueryPlanCaptureMaxCount
public void setQueryPlanCaptureMaxCount(int queryPlanCaptureMaxCount) Set the max number of query plans captured per request. -
getQueryPlanListener
Return the listener used to process captured query plans. -
setQueryPlanListener
Set the listener used to process captured query plans. -
isDumpMetricsOnShutdown
public boolean isDumpMetricsOnShutdown()Return true if metrics should be dumped when the server is shutdown. -
setDumpMetricsOnShutdown
public void setDumpMetricsOnShutdown(boolean dumpMetricsOnShutdown) Set to true if metrics should be dumped when the server is shutdown. -
getDumpMetricsOptions
Return the options for dumping metrics. -
setDumpMetricsOptions
Include 'sql' or 'hash' in options such that they are included in the output.- Parameters:
dumpMetricsOptions
- Example "sql,hash", "sql"
-
isAutoLoadModuleInfo
public boolean isAutoLoadModuleInfo()Return true if entity classes should be loaded and registered via ModuleInfoLoader.When false we either register entity classes via application code or use classpath scanning to find and register entity classes.
-
setLoadModuleInfo
public void setLoadModuleInfo(boolean 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.
-