Class DatabaseConfig
- Direct Known Subclasses:
ServerConfig
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
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionConstruct a Database Configuration for programmatically creating an Database. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(IdGenerator idGenerator) Register a customer IdGenerator instance.voidadd(BeanPersistController beanPersistController) Register a BeanPersistController instance.voidadd(BeanPersistListener beanPersistListener) Register a BeanPersistListener instance.voidadd(BeanPostConstructListener listener) Register a BeanPostConstructListener instance.voidadd(BeanPostLoad postLoad) Register a BeanPostLoad instance.voidadd(BeanQueryAdapter beanQueryAdapter) Register a BeanQueryAdapter instance.voidadd(BulkTableEventListener bulkTableEventListener) Add a BulkTableEventListenervoidRegister all the classes (typically entity classes).voidProgrammatically add classes (typically entities) that this server should use.voidaddCustomMapping(DbType type, String columnDefinition) Add a custom type mapping that applies to all platforms.voidaddCustomMapping(DbType type, String columnDefinition, io.ebean.annotation.Platform platform) Add a custom type mapping.voidaddMappingLocation(String mappingLocation) Add a mapping location to search for xml mapping via class path search.voidaddPackage(String packageName) Add a package to search for entities via class path search.voidaddServerConfigStartup(ServerConfigStartup configStartupListener) Add a ServerConfigStartup.io.ebean.annotation.PersistBatchReturn 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.intReturn the Background executor schedule pool size.intReturn the Background executor shutdown seconds.Return the background executor wrapper.Return the list of BulkTableEventListener instances.intReturn the L2 cache default max idle time in seconds.intReturn the L2 cache default max size.intReturn 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).intReturn the number of DB sequence values that should be preallocated.Return the DataSource.io.ebean.datasource.DataSourceConfigReturn the configuration to build a DataSource using Ebean's own DataSource implementation.Return the JNDI name of the DataSource to use.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.EnumTypeReturn 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.intReturn the Geometry SRID.Return the history table suffix (defaults to _history).Return the custom IdGenerator instances.Return the preferred DB platform IdType.intReturn the default JDBC fetchSize hint for findEach/findEachWhile queries.intReturn 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.JsonFactoryReturn the Jackson JsonFactory to use.Return the JSON include mode used when writing JSON.io.ebean.annotation.MutationDetectionReturn the default MutableDetection to use with@DbJsonusing Jackson.intReturn the default batch size for lazy loading of beans and collections.Return mapping locations to search for xml mapping via class path search.intReturn 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.PersistBatchReturn the PersistBatch mode to use by default at the transaction level.io.ebean.annotation.PersistBatchReturn the JDBC batch mode to use per save(), delete(), insert() or update() request.intReturn 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.intGets the query batch size.intReturn the L2 query cache default max idle time in seconds.intReturn the L2 query cache default max size.intReturn the L2 query cache default max time to live in seconds.intReturn the max number of query plans captured per request.longReturn the time after which a capture query plans request will stop capturing more query plans.longReturn the frequency to capture query plans.Return the listener used to process captured query plans.longReturn the query plan collection threshold in microseconds.intReturn 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.DataSourceConfigReturn the configuration for the read only DataSource.Returns the resource directory.Return the ServerCachePlugin.Return the list of ServerConfigStartup instances.<P> PgetServiceObject(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.longReturn 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.booleanReturn true if all DB column and table names should use quoted identifiers.booleanReturn true if entity classes should be loaded and registered via ModuleInfoLoader.booleanReturn true if dirty beans are automatically persisted.booleanReturn true if Ebean should create a DataSource for use with implicit read only transactions.booleanReturn true (default) if the changelog should be written async.booleanReturn true if inserts should be included in the change log by default.booleanReturn true if the Database instance should be created in offline mode.booleanReturn true if the "drop all ddl" should be skipped.booleanReturn true, if extra-ddl.xml should be executed.booleanReturn true if the DDL should be generated.booleanisDdlRun()Return true if the DDL should be run.booleanReturn true if strict mode is used which includes a check that non-null columns have a default value.booleanReturns the default orderById setting for queries.booleanReturn true if this server should be registered as the "default" server with the Ebean singleton.booleanReturn true if the class path search should be disabled.booleanReturn true if L2 cache is disabled.booleanReturn true if lazy loading is disabled on queries by default.booleanReturn true if this Database is a Document store only instance (has no JDBC DB).booleanReturn true if metrics should be dumped when the server is shutdown.booleanReturn true if Duration should be persisted with nanos precision (SQL DECIMAL).booleanReturn true if LOB's should default to fetch eager.booleanReturn true if eq("someProperty", null) should to generate "1=1" rather than "is null" sql expression.booleanReturn true if native ILIKE expression should be used if supported by the database platform (e.g.booleanWhen false we need explicit@GeneratedValuemapping to assign Identity or Sequence generated values.booleanReturn true to use local only L2 cache.booleanReturn true if LocalTime should be persisted with nanos precision.booleanReturn true if L2 cache notification should run in the foreground.booleanReturn true if periodic capture of query plans is enabled.booleanReturn true if query plan capture is enabled.booleanReturn true if this server should be registered with the Ebean singleton when it is created.booleanReturn true if the DB migration should run on server start.booleanReturn true if L2 bean cache should be skipped once writes have occurred on a transaction.booleanReturn true if transactions should rollback on checked exceptions.booleanReturns true if updates in JDBC batch default to include all properties by default.booleanReturn true if we are running in a JTA Transaction manager.booleanReturns if we use javax.validation.constraints.NotNullvoidLoad settings from application.properties, application.yaml and other sources.voidloadFromProperties(Properties properties) Load the settings from the given propertiesnewPlatformConfig(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.voidputServiceObject(Object configObject) Put a service object into configuration such that it can be passed to a plugin.voidputServiceObject(String key, Object configObject) Put a service object into configuration such that it can be passed to a plugin.voidsetAllQuotedIdentifiers(boolean allQuotedIdentifiers) Set to true if all DB column and table names should use quoted identifiers.voidsetAsOfSysPeriod(String asOfSysPeriod) Set the database column used to support history and 'As of' queries.voidsetAsOfViewSuffix(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.voidsetAutoPersistUpdates(boolean autoPersistUpdates) Set to true if dirty beans are automatically persisted.voidsetAutoReadOnlyDataSource(boolean autoReadOnlyDataSource) Set to true if Ebean should create a DataSource for use with implicit read only transactions.voidsetAutoTuneConfig(AutoTuneConfig autoTuneConfig) Set the configuration for AutoTune.voidsetBackgroundExecutorSchedulePoolSize(int backgroundExecutorSchedulePoolSize) Set the Background executor schedule pool size.voidsetBackgroundExecutorShutdownSecs(int backgroundExecutorShutdownSecs) Set the Background executor shutdown seconds.voidsetBackgroundExecutorWrapper(BackgroundExecutorWrapper backgroundExecutorWrapper) Sets the background executor wrapper.voidsetCacheMaxIdleTime(int cacheMaxIdleTime) Set the L2 cache default max idle time in seconds.voidsetCacheMaxSize(int cacheMaxSize) Set the L2 cache default max size.voidsetCacheMaxTimeToLive(int cacheMaxTimeToLive) Set the L2 cache default max time to live in seconds.voidsetChangeLogAsync(boolean changeLogAsync) Sets if the changelog should be written async (default = true).voidsetChangeLogIncludeInserts(boolean changeLogIncludeInserts) Set if inserts should be included in the change log by default.voidsetChangeLogListener(ChangeLogListener changeLogListener) Set the ChangeLogListener which actually performs the logging of change sets in the background.voidsetChangeLogPrepare(ChangeLogPrepare changeLogPrepare) Set the ChangeLogPrepare.voidsetChangeLogRegister(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.voidsetClasses(List<Class<?>> classes) Set the list of classes (entities, listeners, scalarTypes etc) that should be used for this database.voidsetClassLoadConfig(ClassLoadConfig classLoadConfig) Set the ClassLoadConfig which is used to detect Joda, Java8 types etc and also create new instances of plugins given a className.voidSet the clock used for setting the timestamps (e.g.voidsetConstraintNaming(DbConstraintNaming constraintNaming) Set the constraint naming convention used in DDL generation.voidsetContainerConfig(ContainerConfig containerConfig) Set the container / clustering configuration.voidsetCurrentTenantProvider(CurrentTenantProvider currentTenantProvider) Set the current tenant provider.voidsetCurrentUserProvider(CurrentUserProvider currentUserProvider) Set the CurrentUserProvider.voidsetDatabaseBooleanFalse(String databaseFalse) Set the value to represent FALSE in the database.voidsetDatabaseBooleanTrue(String databaseTrue) Set the value to represent TRUE in the database.voidsetDatabasePlatform(DatabasePlatform databasePlatform) Explicitly set the database platform to use.voidsetDatabasePlatformName(String databasePlatformName) Explicitly set the database platform namevoidsetDatabaseSequenceBatch(int databaseSequenceBatchSize) Set the number of DB sequence values that should be preallocated and cached by Ebean.voidsetDatabaseSequenceBatchSize(int databaseSequenceBatchSize) Set the number of sequences to fetch/preallocate when using DB sequences.voidsetDataSource(DataSource dataSource) Set a DataSource.voidsetDataSourceConfig(io.ebean.datasource.DataSourceConfig dataSourceConfig) Set the configuration required to build a DataSource using Ebean's own DataSource implementation.voidsetDataSourceJndiName(String dataSourceJndiName) Set the JNDI name of the DataSource to use.voidsetDataTimeZone(String dataTimeZone) Set the time zone to use when reading/writing Timestamps via JDBC.voidsetDbEncrypt(DbEncrypt dbEncrypt) Set the DbEncrypt used to encrypt and decrypt properties.voidsetDbOffline(boolean dbOffline) Set to true if the Database instance should be created in offline mode.voidsetDbSchema(String dbSchema) Set the DB schema to use.voidsetDbUuid(PlatformConfig.DbUuid dbUuid) Set the DB type used to store UUID.voidsetDdlCreateOnly(boolean ddlCreateOnly) Set to true if the "drop all ddl" should be skipped.voidsetDdlExtra(boolean ddlExtra) Set to false if you not want to run the extra-ddl.xml scripts.voidsetDdlGenerate(boolean ddlGenerate) Set to true to generate the "create all" DDL on startup.voidsetDdlHeader(String ddlHeader) Set the header to use with DDL generation.voidsetDdlInitSql(String ddlInitSql) Set a SQL script to execute before the "create all" DDL has been run.voidsetDdlPlaceholderMap(Map<String, String> ddlPlaceholderMap) Set a map of placeholder values that are substituted in DDL scripts.voidsetDdlPlaceholders(String ddlPlaceholders) Set a comma and equals delimited placeholders that are substituted in DDL scripts.voidsetDdlRun(boolean ddlRun) Set to true to run the generated "create all DDL" on startup.voidsetDdlSeedSql(String ddlSeedSql) Set a SQL script to execute after the "create all" DDL has been run.voidsetDdlStrictMode(boolean ddlStrictMode) Set to false to turn off strict mode allowing non-null columns to not have a default value.voidsetDefaultEnumType(javax.persistence.EnumType defaultEnumType) voidsetDefaultOrderById(boolean defaultOrderById) Deprecated.voidsetDefaultServer(boolean defaultServer) Set false if you do not want this Database to be registered as the "default" database with the DB singleton.voidsetDisableClasspathSearch(boolean disableClasspathSearch) Set to true to disable the class path search even for the case where no entity bean classes have been registered.voidsetDisableL2Cache(boolean disableL2Cache) Set to true to disable L2 caching.voidsetDisableLazyLoading(boolean disableLazyLoading) Set to true to disable lazy loading by default.voidsetDocStoreConfig(DocStoreConfig docStoreConfig) Set the configuration for the ElasticSearch integration.voidsetDocStoreOnly(boolean docStoreOnly) Set to true if this Database is Document store only instance (has no JDBC DB).voidsetDumpMetricsOnShutdown(boolean dumpMetricsOnShutdown) Set to true if metrics should be dumped when the server is shutdown.voidsetDumpMetricsOptions(String dumpMetricsOptions) Include 'sql' or 'hash' in options such that they are included in the output.voidsetDurationWithNanos(boolean durationWithNanos) Set to true if Duration should be persisted with nanos precision (SQL DECIMAL).voidsetEagerFetchLobs(boolean eagerFetchLobs) Set to true if you want LOB's to be fetch eager by default.voidsetEnabledL2Regions(String enabledL2Regions) Set the enabled L2 cache regions (comma delimited).voidsetEncryptDeployManager(EncryptDeployManager encryptDeployManager) Set the EncryptDeployManager.voidsetEncryptKeyManager(EncryptKeyManager encryptKeyManager) Set the EncryptKeyManager.voidsetEncryptor(Encryptor encryptor) Set the Encryptor used to encrypt data on the java client side (as opposed to DB encryption functions).voidsetExpressionEqualsWithNullAsNoop(boolean expressionEqualsWithNullAsNoop) Set to true if you want eq("someProperty", null) to generate "1=1" rather than "is null" sql expression.voidsetExpressionNativeIlike(boolean expressionNativeIlike) Set to true to use native ILIKE expression if supported by the database platform (e.g.voidsetExternalTransactionManager(ExternalTransactionManager externalTransactionManager) Set the external transaction manager.voidsetFindControllers(List<BeanFindController> findControllers) Set the list of BeanFindController instances.voidsetGeometrySRID(int geometrySRID) Set the Geometry SRID.voidsetHistoryTableSuffix(String historyTableSuffix) Set the history table suffix.voidsetIdGeneratorAutomatic(boolean idGeneratorAutomatic) Set to false such that Id properties require explicit@GeneratedValuemapping before they are assigned Identity or Sequence generation based on platform.voidsetIdGenerators(List<IdGenerator> idGenerators) Set the custom IdGenerator instances.voidSet the preferred DB platform IdType.voidsetJdbcFetchSizeFindEach(int jdbcFetchSizeFindEach) Set the default JDBC fetchSize hint for findEach/findEachWhile queries.voidsetJdbcFetchSizeFindList(int jdbcFetchSizeFindList) Set the default JDBC fetchSize hint for findList queries.voidsetJodaLocalTimeMode(String jodaLocalTimeMode) Set the mode to use for Joda LocalTime support 'normal' or 'utc'.voidsetJsonDate(JsonConfig.Date jsonDate) Set the JSON format to use for Date types.voidsetJsonDateTime(JsonConfig.DateTime jsonDateTime) Set the JSON format to use for DateTime types.voidsetJsonFactory(com.fasterxml.jackson.core.JsonFactory jsonFactory) Set the Jackson JsonFactory to use.voidsetJsonInclude(JsonConfig.Include jsonInclude) Set the JSON include mode used when writing JSON.voidsetJsonMutationDetection(io.ebean.annotation.MutationDetection jsonMutationDetection) Set the default MutableDetection to use with@DbJsonusing Jackson.voidsetLazyLoadBatchSize(int lazyLoadBatchSize) Set the default batch size for lazy loading.voidsetLoadModuleInfo(boolean loadModuleInfo) Set false to turn off automatic registration of entity beans.voidsetLocalOnlyL2Cache(boolean localOnlyL2Cache) Force the use of local only L2 cache.voidsetLocalTimeWithNanos(boolean localTimeWithNanos) Set to true if LocalTime should be persisted with nanos precision.voidsetMappingLocations(List<String> mappingLocations) Set mapping locations to search for xml mapping via class path search.voidsetMaxCallStack(int maxCallStack) Set the max call stack to use for origin location.voidSet the name of the Database.voidsetNamingConvention(NamingConvention namingConvention) Set the NamingConvention.voidsetNotifyL2CacheInForeground(boolean notifyL2CacheInForeground) Set this to true to run L2 cache notification in the foreground.voidsetObjectMapper(Object objectMapper) Set the Jackson ObjectMapper.voidsetPackages(List<String> packages) Set packages to search for entities via class path search.voidsetPersistBatch(io.ebean.annotation.PersistBatch persistBatch) Set the JDBC batch mode to use at the transaction level.voidsetPersistBatching(boolean persistBatching) Deprecated, please migrate to using setPersistBatch().voidsetPersistBatchOnCascade(io.ebean.annotation.PersistBatch persistBatchOnCascade) Set the JDBC batch mode to use per save(), delete(), insert() or update() request.voidsetPersistBatchSize(int persistBatchSize) Set the batch size used for JDBC batching.voidsetPersistControllers(List<BeanPersistController> persistControllers) Register all the BeanPersistController instances.voidsetPersistenceContextScope(PersistenceContextScope persistenceContextScope) Set the PersistenceContext scope to be used if one is not explicitly set on a query.voidsetPersistListeners(List<BeanPersistListener> persistListeners) Register all the BeanPersistListener instances.voidsetPlatformConfig(PlatformConfig platformConfig) Set the configuration for DB platform (such as UUID and custom mappings).voidsetPostConstructListeners(List<BeanPostConstructListener> listeners) Set the list of BeanPostLoader instances.voidsetPostLoaders(List<BeanPostLoad> postLoaders) Set the list of BeanPostLoader instances.voidsetProfilingConfig(ProfilingConfig profilingConfig) Set the configuration for profiling.voidsetQueryAdapters(List<BeanQueryAdapter> queryAdapters) Register all the BeanQueryAdapter instances.voidsetQueryBatchSize(int queryBatchSize) Sets the query batch size.voidsetQueryCacheMaxIdleTime(int queryCacheMaxIdleTime) Set the L2 query cache default max idle time in seconds.voidsetQueryCacheMaxSize(int queryCacheMaxSize) Set the L2 query cache default max size.voidsetQueryCacheMaxTimeToLive(int queryCacheMaxTimeToLive) Set the L2 query cache default max time to live in seconds.voidsetQueryPlanCapture(boolean queryPlanCapture) Set to true to turn on periodic capture of query plans.voidsetQueryPlanCaptureMaxCount(int queryPlanCaptureMaxCount) Set the max number of query plans captured per request.voidsetQueryPlanCaptureMaxTimeMillis(long queryPlanCaptureMaxTimeMillis) Set the time after which a capture query plans request will stop capturing more query plans.voidsetQueryPlanCapturePeriodSecs(long queryPlanCapturePeriodSecs) Set the frequency in seconds to capture query plans.voidsetQueryPlanEnable(boolean queryPlanEnable) Set to true to enable query plan capture.voidsetQueryPlanListener(QueryPlanListener queryPlanListener) Set the listener used to process captured query plans.voidsetQueryPlanThresholdMicros(long queryPlanThresholdMicros) Set the query plan collection threshold in microseconds.voidsetQueryPlanTTLSeconds(int queryPlanTTLSeconds) Set the time to live for ebean's internal query plan.voidsetReadAuditLogger(ReadAuditLogger readAuditLogger) Set the ReadAuditLogger to use.voidsetReadAuditPrepare(ReadAuditPrepare readAuditPrepare) Set the ReadAuditPrepare to use.voidsetReadOnlyDataSource(DataSource readOnlyDataSource) Set the read only DataSource.voidsetReadOnlyDataSourceConfig(io.ebean.datasource.DataSourceConfig readOnlyDataSourceConfig) Set the configuration for the read only DataSource.voidsetRegister(boolean register) Set to false if you do not want this server to be registered with the Ebean singleton when it is created.voidsetResourceDirectory(String resourceDirectory) Sets the resource directory.voidsetRunMigration(boolean runMigration) Set to true to run DB migrations on server start.voidsetServerCachePlugin(ServerCachePlugin serverCachePlugin) Set the ServerCachePlugin to use.voidsetSkipCacheAfterWrite(boolean skipCacheAfterWrite) Set to false when we still want to hit the cache after a write has occurred on a transaction.voidsetSkipDataSourceCheck(boolean skipDataSourceCheck) Set to true to skip the startup DataSource check.voidsetSlowQueryListener(SlowQueryListener slowQueryListener) Set the slow query event listener.voidsetSlowQueryMillis(long slowQueryMillis) Set the slow query time in millis.voidsetTenantCatalogProvider(TenantCatalogProvider tenantCatalogProvider) Set the tenancy catalog provider.voidsetTenantDataSourceProvider(TenantDataSourceProvider tenantDataSourceProvider) Set the tenancy datasource provider.voidsetTenantMode(TenantMode tenantMode) Set the tenancy mode to use.voidsetTenantPartitionColumn(String tenantPartitionColumn) Set the column name used for TenantMode.PARTITION.voidsetTenantSchemaProvider(TenantSchemaProvider tenantSchemaProvider) Set the tenancy schema provider.voidsetTransactionRollbackOnChecked(boolean transactionRollbackOnChecked) Set to true if transactions should by default rollback on checked exceptions.voidsetUpdateAllPropertiesInBatch(boolean updateAllPropertiesInBatch) Set to false if by default updates in JDBC batch should not include all properties.voidsetUseJtaTransactionManager(boolean useJtaTransactionManager) Set to true if we are running in a JTA Transaction manager.voidsetUseValidationNotNull(boolean useValidationNotNull) Controls if Ebean should ignore&x64;javax.validation.contstraints.NotNullor&x64;jakarta.validation.contstraints.NotNullwith respect to generating aNOT NULLcolumn.voidsetUuidNodeId(String uuidNodeId) Sets the V1-UUID-NodeId.voidsetUuidStateFile(String uuidStateFile) Set the UUID state file.voidsetUuidVersion(DatabaseConfig.UuidVersion uuidVersion) Sets the UUID version mode.booleanReturn 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
Return the slow query time in millis. -
setSlowQueryMillis
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
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
Return the Jackson JsonFactory to use.If not set a default implementation will be used.
-
setJsonFactory
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
Return the default MutableDetection to use with@DbJsonusing Jackson.- See Also:
-
DbJson.mutationDetection()
-
setJsonMutationDetection
Set the default MutableDetection to use with@DbJsonusing 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
Return true if this server should be registered with the Ebean singleton when it is created.By default this is set to true.
-
setRegister
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
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
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
Return true if dirty beans are automatically persisted. -
setAutoPersistUpdates
Set to true if dirty beans are automatically persisted. -
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
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
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
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
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
Return the batch size used for JDBC batching. This defaults to 20. -
setPersistBatchSize
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
Gets the query batch size. This defaults to 100.- Returns:
- the query batch size
-
setQueryBatchSize
Sets the query batch size. This defaults to 100.- Parameters:
queryBatchSize- the new query batch size
-
getDefaultEnumType
-
setDefaultEnumType
-
isDisableLazyLoading
Return true if lazy loading is disabled on queries by default. -
setDisableLazyLoading
Set to true to disable lazy loading by default.It can be turned on per query via
Query.setDisableLazyLoading(boolean). -
getLazyLoadBatchSize
Return the default batch size for lazy loading of beans and collections. -
setLazyLoadBatchSize
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
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
Return the default JDBC fetchSize hint for findList queries. -
setJdbcFetchSizeFindList
Set the default JDBC fetchSize hint for findList queries. -
getJdbcFetchSizeFindEach
Return the default JDBC fetchSize hint for findEach/findEachWhile queries. -
setJdbcFetchSizeFindEach
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
Return true if inserts should be included in the change log by default. -
setChangeLogIncludeInserts
Set if inserts should be included in the change log by default. -
isChangeLogAsync
Return true (default) if the changelog should be written async. -
setChangeLogAsync
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
Return the Geometry SRID. -
setGeometrySRID
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
Return true if we are running in a JTA Transaction manager. -
setUseJtaTransactionManager
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
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
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
Return the max call stack to use for origin location. -
setMaxCallStack
Set the max call stack to use for origin location. -
isTransactionRollbackOnChecked
Return true if transactions should rollback on checked exceptions. -
setTransactionRollbackOnChecked
Set to true if transactions should by default rollback on checked exceptions. -
getBackgroundExecutorSchedulePoolSize
Return the Background executor schedule pool size. Defaults to 1. -
setBackgroundExecutorSchedulePoolSize
Set the Background executor schedule pool size. -
getBackgroundExecutorShutdownSecs
Return the Background executor shutdown seconds. This is the time allowed for the pool to shutdown nicely before it is forced shutdown. -
setBackgroundExecutorShutdownSecs
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
Return the L2 cache default max size. -
setCacheMaxSize
Set the L2 cache default max size. -
getCacheMaxIdleTime
Return the L2 cache default max idle time in seconds. -
setCacheMaxIdleTime
Set the L2 cache default max idle time in seconds. -
getCacheMaxTimeToLive
Return the L2 cache default max time to live in seconds. -
setCacheMaxTimeToLive
Set the L2 cache default max time to live in seconds. -
getQueryCacheMaxSize
Return the L2 query cache default max size. -
setQueryCacheMaxSize
Set the L2 query cache default max size. -
getQueryCacheMaxIdleTime
Return the L2 query cache default max idle time in seconds. -
setQueryCacheMaxIdleTime
Set the L2 query cache default max idle time in seconds. -
getQueryCacheMaxTimeToLive
Return the L2 query cache default max time to live in seconds. -
setQueryCacheMaxTimeToLive
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
Return true if all DB column and table names should use quoted identifiers. -
setAllQuotedIdentifiers
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
Return true if this Database is a Document store only instance (has no JDBC DB). -
setDocStoreOnly
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
Return true if the startup DataSource check should be skipped. -
setSkipDataSourceCheck
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
Return the configuration to build a DataSource using Ebean's own DataSource implementation. -
setDataSourceConfig
Set the configuration required to build a DataSource using Ebean's own DataSource implementation. -
isAutoReadOnlyDataSource
Return true if Ebean should create a DataSource for use with implicit read only transactions. -
setAutoReadOnlyDataSource
Set to true if Ebean should create a DataSource for use with implicit read only transactions. -
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. -
getDataSourceJndiName
Return the JNDI name of the DataSource to use. -
setDataSourceJndiName
Set the JNDI name of the DataSource to use.By default a prefix of "java:comp/env/jdbc/" is used to lookup the DataSource. This prefix is not used if dataSourceJndiName starts with "java:".
-
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
Return the number of DB sequence values that should be preallocated. -
setDatabaseSequenceBatch
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
EncryptedAnnotation. -
setEncryptDeployManager
Set the EncryptDeployManager.This is optionally used to programmatically define which columns are encrypted instead of using the
EncryptedAnnotation. -
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
Return true if the Database instance should be created in offline mode. -
setDbOffline
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
Return true if LocalTime should be persisted with nanos precision. -
setLocalTimeWithNanos
Set to true if LocalTime should be persisted with nanos precision.Otherwise it is persisted using java.sql.Time which is seconds precision.
-
isDurationWithNanos
Return true if Duration should be persisted with nanos precision (SQL DECIMAL).Otherwise it is persisted with second precision (SQL INTEGER).
-
setDurationWithNanos
Set to true if Duration should be persisted with nanos precision (SQL DECIMAL).Otherwise it is persisted with second precision (SQL INTEGER).
-
setRunMigration
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
Return true if the DB migration should run on server start. -
setDdlGenerate
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
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
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
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
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
Return true if the DDL should be generated. -
isDdlRun
Return true if the DDL should be run. -
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
Return true if strict mode is used which includes a check that non-null columns have a default value. -
setDdlStrictMode
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
Return true if the class path search should be disabled. -
setDisableClasspathSearch
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
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
Set to false when we still want to hit the cache after a write has occurred on a transaction. -
isUpdateAllPropertiesInBatch
Returns true if updates in JDBC batch default to include all properties by default. -
setUpdateAllPropertiesInBatch
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
Load settings from application.properties, application.yaml and other sources.Uses
avaje-configto 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(). -
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
Return true if eq("someProperty", null) should to generate "1=1" rather than "is null" sql expression. -
setExpressionEqualsWithNullAsNoop
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
Return true if native ILIKE expression should be used if supported by the database platform (e.g. Postgres). -
setExpressionNativeIlike
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
Return true if L2 cache is disabled. -
setDisableL2Cache
Set to true to disable L2 caching. Typically useful in performance testing. -
isLocalOnlyL2Cache
Return true to use local only L2 cache. Effectively ignore l2 cache plugin like ebean-redis etc. -
setLocalOnlyL2Cache
Force the use of local only L2 cache. Effectively ignore l2 cache plugin like ebean-redis etc. -
isUseValidationNotNull
Returns if we use javax.validation.constraints.NotNull -
setUseValidationNotNull
Controls if Ebean should ignore&x64;javax.validation.contstraints.NotNullor&x64;jakarta.validation.contstraints.NotNullwith respect to generating aNOT NULLcolumn.Normally when Ebean sees javax NotNull annotation it means that column is defined as NOT NULL. Set this to
falseand the javax NotNull annotation is effectively ignored (and we instead use Ebean's own NotNull annotation or JPA Column(nullable=false) annotation. -
isNotifyL2CacheInForeground
Return true if L2 cache notification should run in the foreground. -
setNotifyL2CacheInForeground
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
Return the time to live for ebean's internal query plan. -
setQueryPlanTTLSeconds
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
When false we need explicit@GeneratedValuemapping to assign Identity or Sequence generated values. When true Id properties are automatically assigned Identity or Sequence without the GeneratedValue mapping. -
setIdGeneratorAutomatic
Set to false such that Id properties require explicit@GeneratedValuemapping before they are assigned Identity or Sequence generation based on platform. -
isQueryPlanEnable
Return true if query plan capture is enabled. -
setQueryPlanEnable
Set to true to enable query plan capture. -
getQueryPlanThresholdMicros
Return the query plan collection threshold in microseconds. -
setQueryPlanThresholdMicros
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
Return true if periodic capture of query plans is enabled. -
setQueryPlanCapture
Set to true to turn on periodic capture of query plans. -
getQueryPlanCapturePeriodSecs
Return the frequency to capture query plans. -
setQueryPlanCapturePeriodSecs
Set the frequency in seconds to capture query plans. -
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
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
Return the max number of query plans captured per request. -
setQueryPlanCaptureMaxCount
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
Return true if metrics should be dumped when the server is shutdown. -
setDumpMetricsOnShutdown
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
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
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.
-