Class AbstractJpaProperties

java.lang.Object
org.apereo.cas.configuration.model.support.jpa.AbstractJpaProperties
All Implemented Interfaces:
Serializable, CasFeatureModule
Direct Known Subclasses:
AuditJdbcProperties, BaseJdbcAuthenticationProperties, JdbcAcceptableUsagePolicyProperties, JdbcMonitorProperties, JdbcPasswordManagementProperties, JdbcPrincipalAttributesProperties, JdbcSecurityActuatorEndpointsMonitorProperties, JdbcThrottleProperties, JpaConsentProperties, JpaEventsProperties, JpaGoogleAuthenticatorMultifactorProperties, JpaOidcJsonWebKeystoreProperties, JpaSamlMetadataProperties, JpaServiceRegistryProperties, JpaTicketRegistryProperties, JpaTrustedDevicesMultifactorProperties, Pac4jSamlServiceProviderMetadataJdbcProperties, PasswordlessAuthenticationJpaTokensProperties, SurrogateJdbcAuthenticationProperties, UmaResourceSetJpaProperties, WebAuthnJpaMultifactorProperties, YubiKeyJpaMultifactorProperties

@RequiresModule(name="cas-server-support-jdbc-drivers") public abstract class AbstractJpaProperties extends Object implements CasFeatureModule, Serializable
Common properties for all jpa configs.
Since:
5.0.0
See Also:
  • Constructor Details

    • AbstractJpaProperties

      public AbstractJpaProperties()
  • Method Details

    • getDialect

      public String getDialect()
      The database dialect is a configuration setting for platform independent software (JPA, Hibernate, etc) which allows such software to translate its generic SQL statements into vendor specific DDL, DML.
    • getDdlAuto

      public String getDdlAuto()
      Hibernate feature to automatically validate and exports DDL to the schema. By default, creates and drops the schema automatically when a session is starts and ends. Setting the value to validate or none may be more desirable for production, but any of the following options can be used:
      • validate: Validate the schema, but make no changes to the database.
      • update: Update the schema.
      • create: Create the schema, destroying previous data.
      • create-drop: Drop the schema at the end of the session.
      • none: Do nothing.

      Note that during a version migration where any schema has changed create-drop will result in the loss of all data as soon as CAS is started. For transient data like tickets this is probably not an issue, but in cases like the audit table important data could be lost. Using `update`, while safe for data, is confirmed to result in invalid database state. validate or none settings are likely the only safe options for production use.

      For more info, see this.
    • getDriverClass

      public String getDriverClass()
      The JDBC driver used to connect to the database.
    • getUrl

      public String getUrl()
      The database connection URL.
    • getUser

      public String getUser()
      The database user.

      The database user must have sufficient permissions to be able to handle schema changes and updates, when needed.

    • getPassword

      public String getPassword()
      The database connection password.
    • getDefaultCatalog

      public String getDefaultCatalog()
      Qualifies unqualified table names with the given catalog in generated SQL.
    • getDefaultSchema

      public String getDefaultSchema()
      Qualify unqualified table names with the given schema/tablespace in generated SQL.
    • getHealthQuery

      public String getHealthQuery()
      The SQL query to be executed to test the validity of connections. This is for "legacy" databases that do not support the JDBC4 Connection.isValid() API.
    • getIdleTimeout

      public String getIdleTimeout()
      Controls the maximum amount of time that a connection is allowed to sit idle in the pool.
    • getDataSourceName

      public String getDataSourceName()
      Attempts to do a JNDI data source look up for the data source name specified. Will attempt to locate the data source object as is.
    • getProperties

      public Map<String,String> getProperties()
      Additional settings provided by Hibernate (or the connection provider) in form of key-value pairs.
    • getPool

      public ConnectionPoolingProperties getPool()
      Database connection pooling settings.
    • getLeakThreshold

      public String getLeakThreshold()
      Controls the amount of time that a connection can be out of the pool before a message is logged indicating a possible connection leak.
    • isGenerateStatistics

      public boolean isGenerateStatistics()
      Allow hibernate to generate query statistics.
    • getBatchSize

      public int getBatchSize()
      A non-zero value enables use of JDBC2 batch updates by Hibernate. e.g. recommended values between 5 and 30.
    • getFetchSize

      public int getFetchSize()
      Used to specify number of rows to be fetched in a select query.
    • getFailFastTimeout

      public long getFailFastTimeout()
      Set the pool initialization failure timeout.
      • Any value greater than zero will be treated as a timeout for pool initialization. The calling thread will be blocked from continuing until a successful connection to the database, or until the timeout is reached. If the timeout is reached, then a PoolInitializationException will be thrown.
      • A value of zero will not prevent the pool from starting in the case that a connection cannot be obtained. However, upon start the pool will attempt to obtain a connection and validate that the connectionTestQuery and connectionInitSql are valid. If those validations fail, an exception will be thrown. If a connection cannot be obtained, the validation is skipped and the the pool will start and continue to try to obtain connections in the background. This can mean that callers to DataSource#getConnection() may encounter exceptions.
      • A value less than zero will not bypass any connection attempt and validation during startup, and therefore the pool will start immediately. The pool will continue to try to obtain connections in the background. This can mean that callers to DataSource#getConnection() may encounter exceptions.
      Note that if this timeout value is greater than or equal to zero (0), and therefore an initial connection validation is performed, this timeout does not override the connectionTimeout or validationTimeout; they will be honored before this timeout is applied. The default value is one millisecond.
    • isIsolateInternalQueries

      public boolean isIsolateInternalQueries()
      This property determines whether data source isolates internal pool queries, such as the connection alive test, in their own transaction.

      Since these are typically read-only queries, it is rarely necessary to encapsulate them in their own transaction. This property only applies if autocommit is disabled.

    • isAutocommit

      public boolean isAutocommit()
      The default auto-commit behavior of connections in the pool. Determined whether queries such as update/insert should be immediately executed without waiting for an underlying transaction.
    • isReadOnly

      public boolean isReadOnly()
      Configures the Connections to be added to the pool as read-only Connections.
    • getPhysicalNamingStrategyClassName

      public String getPhysicalNamingStrategyClassName()
      Fully-qualified name of the class that can control the physical naming strategy of hibernate.
    • getIsolationLevelName

      public String getIsolationLevelName()
      Defines the isolation level for transactions.
      See Also:
      • TransactionDefinition
    • getPropagationBehaviorName

      public String getPropagationBehaviorName()
      Defines the propagation behavior for transactions.
      See Also:
      • TransactionDefinition
    • setDialect

      public AbstractJpaProperties setDialect(String dialect)
      The database dialect is a configuration setting for platform independent software (JPA, Hibernate, etc) which allows such software to translate its generic SQL statements into vendor specific DDL, DML.
      Returns:
      this.
    • setDdlAuto

      public AbstractJpaProperties setDdlAuto(String ddlAuto)
      Hibernate feature to automatically validate and exports DDL to the schema. By default, creates and drops the schema automatically when a session is starts and ends. Setting the value to validate or none may be more desirable for production, but any of the following options can be used:
      • validate: Validate the schema, but make no changes to the database.
      • update: Update the schema.
      • create: Create the schema, destroying previous data.
      • create-drop: Drop the schema at the end of the session.
      • none: Do nothing.

      Note that during a version migration where any schema has changed create-drop will result in the loss of all data as soon as CAS is started. For transient data like tickets this is probably not an issue, but in cases like the audit table important data could be lost. Using `update`, while safe for data, is confirmed to result in invalid database state. validate or none settings are likely the only safe options for production use.

      For more info, see this.
      Returns:
      this.
    • setDriverClass

      public AbstractJpaProperties setDriverClass(String driverClass)
      The JDBC driver used to connect to the database.
      Returns:
      this.
    • setUrl

      public AbstractJpaProperties setUrl(String url)
      The database connection URL.
      Returns:
      this.
    • setUser

      public AbstractJpaProperties setUser(String user)
      The database user.

      The database user must have sufficient permissions to be able to handle schema changes and updates, when needed.

      Returns:
      this.
    • setPassword

      public AbstractJpaProperties setPassword(String password)
      The database connection password.
      Returns:
      this.
    • setDefaultCatalog

      public AbstractJpaProperties setDefaultCatalog(String defaultCatalog)
      Qualifies unqualified table names with the given catalog in generated SQL.
      Returns:
      this.
    • setDefaultSchema

      public AbstractJpaProperties setDefaultSchema(String defaultSchema)
      Qualify unqualified table names with the given schema/tablespace in generated SQL.
      Returns:
      this.
    • setHealthQuery

      public AbstractJpaProperties setHealthQuery(String healthQuery)
      The SQL query to be executed to test the validity of connections. This is for "legacy" databases that do not support the JDBC4 Connection.isValid() API.
      Returns:
      this.
    • setIdleTimeout

      public AbstractJpaProperties setIdleTimeout(String idleTimeout)
      Controls the maximum amount of time that a connection is allowed to sit idle in the pool.
      Returns:
      this.
    • setDataSourceName

      public AbstractJpaProperties setDataSourceName(String dataSourceName)
      Attempts to do a JNDI data source look up for the data source name specified. Will attempt to locate the data source object as is.
      Returns:
      this.
    • setProperties

      public AbstractJpaProperties setProperties(Map<String,String> properties)
      Additional settings provided by Hibernate (or the connection provider) in form of key-value pairs.
      Returns:
      this.
    • setPool

      Database connection pooling settings.
      Returns:
      this.
    • setLeakThreshold

      public AbstractJpaProperties setLeakThreshold(String leakThreshold)
      Controls the amount of time that a connection can be out of the pool before a message is logged indicating a possible connection leak.
      Returns:
      this.
    • setGenerateStatistics

      public AbstractJpaProperties setGenerateStatistics(boolean generateStatistics)
      Allow hibernate to generate query statistics.
      Returns:
      this.
    • setBatchSize

      public AbstractJpaProperties setBatchSize(int batchSize)
      A non-zero value enables use of JDBC2 batch updates by Hibernate. e.g. recommended values between 5 and 30.
      Returns:
      this.
    • setFetchSize

      public AbstractJpaProperties setFetchSize(int fetchSize)
      Used to specify number of rows to be fetched in a select query.
      Returns:
      this.
    • setFailFastTimeout

      public AbstractJpaProperties setFailFastTimeout(long failFastTimeout)
      Set the pool initialization failure timeout.
      • Any value greater than zero will be treated as a timeout for pool initialization. The calling thread will be blocked from continuing until a successful connection to the database, or until the timeout is reached. If the timeout is reached, then a PoolInitializationException will be thrown.
      • A value of zero will not prevent the pool from starting in the case that a connection cannot be obtained. However, upon start the pool will attempt to obtain a connection and validate that the connectionTestQuery and connectionInitSql are valid. If those validations fail, an exception will be thrown. If a connection cannot be obtained, the validation is skipped and the the pool will start and continue to try to obtain connections in the background. This can mean that callers to DataSource#getConnection() may encounter exceptions.
      • A value less than zero will not bypass any connection attempt and validation during startup, and therefore the pool will start immediately. The pool will continue to try to obtain connections in the background. This can mean that callers to DataSource#getConnection() may encounter exceptions.
      Note that if this timeout value is greater than or equal to zero (0), and therefore an initial connection validation is performed, this timeout does not override the connectionTimeout or validationTimeout; they will be honored before this timeout is applied. The default value is one millisecond.
      Returns:
      this.
    • setIsolateInternalQueries

      public AbstractJpaProperties setIsolateInternalQueries(boolean isolateInternalQueries)
      This property determines whether data source isolates internal pool queries, such as the connection alive test, in their own transaction.

      Since these are typically read-only queries, it is rarely necessary to encapsulate them in their own transaction. This property only applies if autocommit is disabled.

      Returns:
      this.
    • setAutocommit

      public AbstractJpaProperties setAutocommit(boolean autocommit)
      The default auto-commit behavior of connections in the pool. Determined whether queries such as update/insert should be immediately executed without waiting for an underlying transaction.
      Returns:
      this.
    • setReadOnly

      public AbstractJpaProperties setReadOnly(boolean readOnly)
      Configures the Connections to be added to the pool as read-only Connections.
      Returns:
      this.
    • setPhysicalNamingStrategyClassName

      public AbstractJpaProperties setPhysicalNamingStrategyClassName(String physicalNamingStrategyClassName)
      Fully-qualified name of the class that can control the physical naming strategy of hibernate.
      Returns:
      this.
    • setIsolationLevelName

      public AbstractJpaProperties setIsolationLevelName(String isolationLevelName)
      Defines the isolation level for transactions.
      Returns:
      this.
      See Also:
      • TransactionDefinition
    • setPropagationBehaviorName

      public AbstractJpaProperties setPropagationBehaviorName(String propagationBehaviorName)
      Defines the propagation behavior for transactions.
      Returns:
      this.
      See Also:
      • TransactionDefinition